From 53b2a150413d0e6841e172a7eedc39dd209e1b29 Mon Sep 17 00:00:00 2001 From: TaehunPark Date: Tue, 18 Oct 2022 11:19:21 +0900 Subject: [PATCH 1/3] =?UTF-8?q?fix:=EB=B0=A9=EC=97=AD=EC=A1=B0=EC=82=AC?= =?UTF-8?q?=EC=8B=A4=20=EC=98=81=EC=83=81=EB=85=B9=ED=99=94=EC=9E=A5?= =?UTF-8?q?=EB=B9=84=20=EC=82=AC=EC=9A=A9=EB=8C=80=EC=9E=A5=20=EC=99=84?= =?UTF-8?q?=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/dbnt/faisp/equip/EquipController.java | 118 +++++++- .../dbnt/faisp/equip/mapper/EquipMapper.java | 3 + .../com/dbnt/faisp/equip/model/UseList.java | 17 +- .../equip/repository/UseListRepository.java | 6 + .../faisp/equip/service/EquipService.java | 39 +++ src/main/java/com/dbnt/faisp/util/Utils.java | 111 +++++++ .../resources/mybatisMapper/EquipMapper.xml | 99 ++++++- .../resources/static/js/equip/cellPhone.js | 9 - src/main/resources/static/js/equip/pvre.js | 56 ---- src/main/resources/static/js/equip/use.js | 271 ++++++++++++++++++ .../templates/equip/equipEditModal.html | 3 +- .../templates/equip/equipHistory.html | 2 - .../templates/equip/equipModifyModal.html | 3 +- .../templates/equip/pvreUseList.html | 60 ++-- .../resources/templates/equip/qirUseList.html | 155 ++++++++++ .../{pvreEditModal.html => useEditModal.html} | 15 +- .../resources/templates/equip/useHistory.html | 84 ++++++ .../templates/equip/useModifyModal.html | 78 +++++ 18 files changed, 1013 insertions(+), 116 deletions(-) delete mode 100644 src/main/resources/static/js/equip/pvre.js create mode 100644 src/main/resources/static/js/equip/use.js create mode 100644 src/main/resources/templates/equip/qirUseList.html rename src/main/resources/templates/equip/{pvreEditModal.html => useEditModal.html} (82%) create mode 100644 src/main/resources/templates/equip/useHistory.html create mode 100644 src/main/resources/templates/equip/useModifyModal.html diff --git a/src/main/java/com/dbnt/faisp/equip/EquipController.java b/src/main/java/com/dbnt/faisp/equip/EquipController.java index 00edb5d5..c08a6858 100644 --- a/src/main/java/com/dbnt/faisp/equip/EquipController.java +++ b/src/main/java/com/dbnt/faisp/equip/EquipController.java @@ -7,8 +7,6 @@ import com.dbnt.faisp.equip.model.Equip; import com.dbnt.faisp.equip.model.EquipLog; import com.dbnt.faisp.equip.model.UseList; import com.dbnt.faisp.equip.service.EquipService; -import com.dbnt.faisp.fipTarget.model.PartInfo; -import com.dbnt.faisp.fipTarget.service.FipTargetService; import com.dbnt.faisp.organMgt.service.OrganConfigService; import com.dbnt.faisp.userInfo.model.UserInfo; import com.dbnt.faisp.userInfo.service.UserInfoService; @@ -42,7 +40,6 @@ public class EquipController { private final EquipService equipService; private final AuthMgtService authMgtService; private final OrganConfigService organConfigService; - private final FipTargetService fipTargetService; private final UserInfoService userInfoService; @GetMapping("/equipStatus") @@ -142,7 +139,6 @@ public class EquipController { @PostMapping("/epuipDelete") public void epuipDelete(@AuthenticationPrincipal UserInfo loginUser, @RequestBody List equip){ equipService.equipDelete(equip,loginUser); - } @GetMapping("/getEquipImg") @@ -296,7 +292,22 @@ public class EquipController { ModelAndView mav = new ModelAndView("equip/pvreUseList"); useList.setDownOrganCdList(loginUser.getDownOrganCdList()); useList.setUseType("PVRE"); + //엑셀다운 + if(useList.getExcel() != null && useList.getExcel().equals("Y")){ + String[] headers = { "use_no", "sosok", "use_dt", "detail_type_name", "people_cnt", "description", "wrt_dt"}; + String[] headerNames = { "연번", "경찰서","사용일시", "사용사유", "사용인원", "비고", "최종수정일"}; + String[] columnType = { "String", "String","String", "String", "int", "String", "String"}; + String sheetName = "휴대용 녹화장비 사용 대장"; + String excelFileName = "휴대용 녹화장비 사용 대장"; + List useExcelList= equipService.selectUseList(useList); + try { + Utils.useListToExcel(useExcelList, response, headers, headerNames, columnType, sheetName, excelFileName); + } catch (IOException e) { + + } + return null; + } //메뉴권한 확인 String accessAuth = authMgtService.selectAccessConfigList(loginUser.getUserSeq(), "/equip/pvreUseList").get(0).getAccessAuth(); mav.addObject("accessAuth", accessAuth); @@ -304,21 +315,27 @@ public class EquipController { mav.addObject("useList", equipService.selectUseList(useList)); useList.setContentCnt(equipService.selectUseListCnt(useList)); useList.setPaginationInfo(); + mav.addObject("organList", equipService.selectOrganList(useList)); mav.addObject("searchParams", useList); - return mav; } - @GetMapping("/pvreEditModal") - public ModelAndView pvreEditModal(@AuthenticationPrincipal UserInfo loginUser,UseList useList) { - ModelAndView mav = new ModelAndView("equip/pvreEditModal"); + @GetMapping("/useEditModal") + public ModelAndView useEditModal(@AuthenticationPrincipal UserInfo loginUser,UseList useList) { + ModelAndView mav = new ModelAndView("equip/useEditModal"); useList.setDownOrganCdList(loginUser.getDownOrganCdList()); mav.addObject("organList", equipService.selectOrganList(useList)); mav.addObject("userOrgan", loginUser.getOgCd()); - mav.addObject("useType", "PVRE"); + mav.addObject("useType", useList.getUseType()); //메뉴권한 확인 - String accessAuth = authMgtService.selectAccessConfigList(loginUser.getUserSeq(), "/equip/pvreUseList").get(0).getAccessAuth(); - mav.addObject("accessAuth", accessAuth); + String accessAuth; + if(useList.getUseType().equals("PVRE")) { + accessAuth = authMgtService.selectAccessConfigList(loginUser.getUserSeq(), "/equip/pvreUseList").get(0).getAccessAuth(); + mav.addObject("accessAuth", accessAuth); + }else if(useList.getUseType().equals("QIR")) { + accessAuth = authMgtService.selectAccessConfigList(loginUser.getUserSeq(), "/equip/qirUseList").get(0).getAccessAuth(); + mav.addObject("accessAuth", accessAuth); + } return mav; } @@ -331,6 +348,85 @@ public class EquipController { useList.setWrtDt(LocalDateTime.now()); equipService.saveUse(useList); } + + @GetMapping("/useModifyModal") + public ModelAndView useModifyModal(@AuthenticationPrincipal UserInfo loginUser,UseList useList) { + ModelAndView mav = new ModelAndView("equip/useModifyModal"); + useList.setDownOrganCdList(loginUser.getDownOrganCdList()); + mav.addObject("organList", equipService.selectOrganList(useList)); + mav.addObject("info", equipService.selectUseInfo(useList)); + //메뉴권한 확인 + String accessAuth; + if(useList.getUseType().equals("PVRE")) { + accessAuth = authMgtService.selectAccessConfigList(loginUser.getUserSeq(), "/equip/pvreUseList").get(0).getAccessAuth(); + mav.addObject("accessAuth", accessAuth); + }else if(useList.getUseType().equals("QIR")) { + accessAuth = authMgtService.selectAccessConfigList(loginUser.getUserSeq(), "/equip/qirUseList").get(0).getAccessAuth(); + mav.addObject("accessAuth", accessAuth); + } + return mav; + } + + @PostMapping("/updateUse") + public UseList uadateUse(@AuthenticationPrincipal UserInfo loginUser,UseList useList){ + useList.setWrtOrgan(loginUser.getOgCd()); + useList.setWrtPart(loginUser.getOfcCd()); + useList.setWrtUserSeq(loginUser.getUserSeq()); + useList.setWrtNm(loginUser.getUserId()); + useList.setWrtDt(LocalDateTime.now()); + return equipService.updateUse(useList); + } + + @GetMapping("/useHistory") + public ModelAndView useHistory(@AuthenticationPrincipal UserInfo loginUser,UseList useList) { + ModelAndView mav = new ModelAndView("equip/useHistory"); + mav.addObject("infoList", equipService.selectUseInfoList(useList)); + return mav; + } + + @GetMapping("/HistoryView") + @ResponseBody + public UseList HistoryView(UseList useList){ + return equipService.selectUseInfo(useList); + } + + @PostMapping("/useDelete") + public void useDelete(@RequestBody List useList){ + equipService.useDelete(useList); + } + + @GetMapping("/qirUseList") + public ModelAndView qirUseList(@AuthenticationPrincipal UserInfo loginUser,UseList useList,HttpServletResponse response) { + ModelAndView mav = new ModelAndView("equip/qirUseList"); + useList.setDownOrganCdList(loginUser.getDownOrganCdList()); + useList.setUseType("QIR"); + //엑셀다운 + if(useList.getExcel() != null && useList.getExcel().equals("Y")){ + String[] headers = { "use_no", "sosok", "use_dt", "detail_type_name", "people_cnt", "description", "wrt_dt"}; + String[] headerNames = { "연번", "경찰서","사용일시", "사용사유", "사용인원", "비고", "최종수정일"}; + String[] columnType = { "String", "String","String", "String", "int", "String", "String"}; + String sheetName = "방역조사실 사용대장"; + String excelFileName = "방역조사실 사용대장"; + List useExcelList= equipService.selectUseList(useList); + + try { + Utils.useListToExcel(useExcelList, response, headers, headerNames, columnType, sheetName, excelFileName); + } catch (IOException e) { + + } + return null; + } + //메뉴권한 확인 + String accessAuth = authMgtService.selectAccessConfigList(loginUser.getUserSeq(), "/equip/qirUseList").get(0).getAccessAuth(); + mav.addObject("accessAuth", accessAuth); + useList.setQueryInfo(); + mav.addObject("useList", equipService.selectUseList(useList)); + useList.setContentCnt(equipService.selectUseListCnt(useList)); + useList.setPaginationInfo(); + mav.addObject("searchParams", useList); + mav.addObject("organList", equipService.selectOrganList(useList)); + return mav; + } diff --git a/src/main/java/com/dbnt/faisp/equip/mapper/EquipMapper.java b/src/main/java/com/dbnt/faisp/equip/mapper/EquipMapper.java index 65277dfd..26c21788 100644 --- a/src/main/java/com/dbnt/faisp/equip/mapper/EquipMapper.java +++ b/src/main/java/com/dbnt/faisp/equip/mapper/EquipMapper.java @@ -45,6 +45,9 @@ public interface EquipMapper { Integer selectUseListCnt(UseList useList); + UseList selectUseInfo(UseList useList); + + } diff --git a/src/main/java/com/dbnt/faisp/equip/model/UseList.java b/src/main/java/com/dbnt/faisp/equip/model/UseList.java index 29201d6a..d24f3d7b 100644 --- a/src/main/java/com/dbnt/faisp/equip/model/UseList.java +++ b/src/main/java/com/dbnt/faisp/equip/model/UseList.java @@ -16,7 +16,6 @@ import javax.persistence.*; import java.io.Serializable; import java.time.LocalDate; import java.time.LocalDateTime; -import java.util.Date; @Getter @@ -41,7 +40,8 @@ public class UseList extends BaseModel implements Serializable{ @Column(name = "use_type") private String useType; @Column(name = "use_dt") - private String useDt; + @DateTimeFormat(pattern = "yyyy-MM-dd") + private LocalDate useDt; @Column(name = "detail_type") private String detailType; @Column(name = "detail_self") @@ -67,12 +67,25 @@ public class UseList extends BaseModel implements Serializable{ @Transient private String excel; + @Transient + private String sosok; + @Transient private String year; @Transient private String detailTypeName; +@Override +public String toString() { + return "UseList [mgtOrgan=" + mgtOrgan + ", useNo=" + useNo + ", versionNo=" + versionNo + ", useType=" + useType + + ", useDt=" + useDt + ", detailType=" + detailType + ", detailSelf=" + detailSelf + ", peopleCnt=" + + peopleCnt + ", description=" + description + ", wrtOrgan=" + wrtOrgan + ", wrtPart=" + wrtPart + + ", wrtUserGrd=" + wrtUserGrd + ", wrtUserSeq=" + wrtUserSeq + ", wrtNm=" + wrtNm + ", wrtDt=" + wrtDt + + ", excel=" + excel + ", sosok=" + sosok + ", year=" + year + ", detailTypeName=" + detailTypeName + "]"; +} + + @Embeddable @Data @NoArgsConstructor diff --git a/src/main/java/com/dbnt/faisp/equip/repository/UseListRepository.java b/src/main/java/com/dbnt/faisp/equip/repository/UseListRepository.java index d9683f6c..42211e23 100644 --- a/src/main/java/com/dbnt/faisp/equip/repository/UseListRepository.java +++ b/src/main/java/com/dbnt/faisp/equip/repository/UseListRepository.java @@ -2,12 +2,18 @@ package com.dbnt.faisp.equip.repository; import com.dbnt.faisp.equip.model.UseList; +import java.util.List; + import org.springframework.data.jpa.repository.JpaRepository; public interface UseListRepository extends JpaRepository { + List findByMgtOrganAndUseNoAndUseTypeOrderByVersionNoDesc(String mgtOrgan, String useNo, String useType); + + void deleteByMgtOrganAndUseNoAndUseType(String mgtOrgan, String useNo, String useType); + diff --git a/src/main/java/com/dbnt/faisp/equip/service/EquipService.java b/src/main/java/com/dbnt/faisp/equip/service/EquipService.java index aecb2cbf..a6024ca2 100644 --- a/src/main/java/com/dbnt/faisp/equip/service/EquipService.java +++ b/src/main/java/com/dbnt/faisp/equip/service/EquipService.java @@ -9,6 +9,7 @@ import com.dbnt.faisp.equip.model.EquipFile; import com.dbnt.faisp.equip.model.EquipFile.EquipFileId; import com.dbnt.faisp.equip.model.EquipLog; import com.dbnt.faisp.equip.model.UseList; +import com.dbnt.faisp.equip.model.UseList.UseListId; import com.dbnt.faisp.equip.repository.CellPhoneRepository; import com.dbnt.faisp.equip.repository.EquipFileRepository; import com.dbnt.faisp.equip.repository.EquipLogRepository; @@ -351,6 +352,44 @@ public class EquipService { public Integer selectUseListCnt(UseList useList) { return equipMapper.selectUseListCnt(useList); } + + public UseList selectUseInfo(UseList useList) { + return equipMapper.selectUseInfo(useList); + } + + @Transactional + public UseList updateUse(UseList useList) { + UseList dbUseList = useListRepository + .findById(new UseListId(useList.getMgtOrgan(),useList.getUseNo(),useList.getVersionNo(),useList.getUseType())).orElse(null); + UseList useTmp = new UseList(); + useTmp.setMgtOrgan(dbUseList.getMgtOrgan()); + useTmp.setUseNo(dbUseList.getUseNo()); + useTmp.setVersionNo(dbUseList.getVersionNo()+1); + useTmp.setUseType(dbUseList.getUseType()); + useTmp.setUseDt(useList.getUseDt()); + useTmp.setDetailType(useList.getDetailType()); + useTmp.setDetailSelf(useList.getDetailSelf()); + useTmp.setPeopleCnt(useList.getPeopleCnt()); + useTmp.setDescription(useList.getDescription()); + useTmp.setWrtOrgan(useList.getWrtOrgan()); + useTmp.setWrtPart(useList.getWrtPart()); + useTmp.setWrtUserSeq(useList.getWrtUserSeq()); + useTmp.setWrtNm(useList.getWrtNm()); + useTmp.setWrtDt(useList.getWrtDt()); + return useListRepository.save(useTmp); + + } + + public List selectUseInfoList(UseList useList) { + return useListRepository.findByMgtOrganAndUseNoAndUseTypeOrderByVersionNoDesc(useList.getMgtOrgan(),useList.getUseNo(),useList.getUseType()); + } + + @Transactional + public void useDelete(List useList) { + for(UseList use:useList) { + useListRepository.deleteByMgtOrganAndUseNoAndUseType(use.getMgtOrgan(),use.getUseNo(),use.getUseType()); + } + } diff --git a/src/main/java/com/dbnt/faisp/util/Utils.java b/src/main/java/com/dbnt/faisp/util/Utils.java index e18d231e..03c19b6c 100644 --- a/src/main/java/com/dbnt/faisp/util/Utils.java +++ b/src/main/java/com/dbnt/faisp/util/Utils.java @@ -26,6 +26,7 @@ import org.apache.poi.xssf.usermodel.XSSFDataFormat; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import com.dbnt.faisp.equip.model.CellPhone; +import com.dbnt.faisp.equip.model.UseList; import com.dbnt.faisp.fipTarget.model.PartInfo; import com.dbnt.faisp.fipTarget.model.PartWork; @@ -749,6 +750,116 @@ public class Utils { } } + + public static void useListToExcel(List useExcelList, HttpServletResponse response, String[] headers, + String[] headerNames, String[] columnType, String sheetName, String excelFileName) throws IOException { + if(Utils.isNotEmpty(useExcelList)) { + // 메모리에 100개의 행을 유지합니다. 행의 수가 넘으면 디스크에 적습니다. + XSSFWorkbook wb = new XSSFWorkbook(); + Sheet sheet = wb.createSheet(sheetName); + Row headerRow = sheet.createRow(0); + CellStyle cellStyle1 = wb.createCellStyle(); //쉼표들어간 숫자 양식 + CellStyle cellStyle2 = wb.createCellStyle(); //숫자양식 + CellStyle headerStyle = wb.createCellStyle(); //숫자양식 + CellStyle headerStyle2 = wb.createCellStyle(); + CellStyle headerStyle3 = wb.createCellStyle(); + + XSSFDataFormat format = wb.createDataFormat(); + cellStyle1.setAlignment(HorizontalAlignment.CENTER); + cellStyle2.setDataFormat(format.getFormat("#,##0")); + cellStyle2.setAlignment(HorizontalAlignment.CENTER); + headerStyle2.setBorderTop(BorderStyle.THIN); + headerStyle2.setBorderBottom(BorderStyle.THIN); + headerStyle2.setBorderLeft(BorderStyle.THIN); + headerStyle2.setBorderRight(BorderStyle.THIN); + headerStyle2.setAlignment(HorizontalAlignment.CENTER); + headerStyle2.setFillPattern(FillPatternType.SOLID_FOREGROUND); + headerStyle2.setFillForegroundColor((short)3); + headerStyle2.setFillForegroundColor(IndexedColors.LIME.getIndex()); + headerStyle.setAlignment(HorizontalAlignment.CENTER); + headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + headerStyle.setFillForegroundColor((short)3); + headerStyle.setFillForegroundColor(IndexedColors.LIME.getIndex()); + headerStyle3.setBorderTop(BorderStyle.THIN); + headerStyle3.setBorderBottom(BorderStyle.THIN); + headerStyle3.setBorderLeft(BorderStyle.THIN); + headerStyle3.setBorderRight(BorderStyle.THIN); + headerStyle3.setAlignment(HorizontalAlignment.CENTER); + headerStyle3.setFillPattern(FillPatternType.SOLID_FOREGROUND); + headerStyle3.setFillForegroundColor((short)3); + headerStyle3.setFillForegroundColor(IndexedColors.LIME.getIndex()); + //로우그리기 + for(int i=0; i"); + out.write(""); + out.write(""); + out.write(""); + out.write(""); + out.write(""); + + out.flush(); + out.close(); + } + + } diff --git a/src/main/resources/mybatisMapper/EquipMapper.xml b/src/main/resources/mybatisMapper/EquipMapper.xml index ae608c15..2bc02baf 100644 --- a/src/main/resources/mybatisMapper/EquipMapper.xml +++ b/src/main/resources/mybatisMapper/EquipMapper.xml @@ -414,7 +414,9 @@ #{item} order by cm.wrt_dt desc + limit #{rowCnt} offset #{firstIndex} + + + + and ul.mgt_organ = #{mgtOrgan} + + + and ul.use_no like '%'||#{useNo}||'%' + + + and ul.detail_type = #{detailType} + + + + and ul.use_dt >= #{startDate}::date + + + and ul.use_dt <= #{endDate}::date+1 + + + + + and ul.wrt_dt >= #{startDate}::date + + + and ul.wrt_dt <= #{endDate}::date+1 + + + + + + \ No newline at end of file diff --git a/src/main/resources/static/js/equip/cellPhone.js b/src/main/resources/static/js/equip/cellPhone.js index b970c839..6ed480c5 100644 --- a/src/main/resources/static/js/equip/cellPhone.js +++ b/src/main/resources/static/js/equip/cellPhone.js @@ -64,15 +64,6 @@ $(document).on('click', '.cellPhoneTr', function (event){ } }); -$(document).on('click', '.affairTr', function (event){ - const target = event.target; - if(!(target.className === "apprvTd" || $(target).parents(".apprvTd").length>0)){ - $(".trChkBox").prop("checked", false); - $(this).find(".trChkBox").prop("checked", true); - getAffairViewModal(Number($(this).find(".affairKey").val())); - } -}) - function showModal(phoneKey){ $.ajax({ url: '/equip/cellPhoneEditModal', diff --git a/src/main/resources/static/js/equip/pvre.js b/src/main/resources/static/js/equip/pvre.js deleted file mode 100644 index fefca62d..00000000 --- a/src/main/resources/static/js/equip/pvre.js +++ /dev/null @@ -1,56 +0,0 @@ - -$(document).on('click', '#addPvre', function (){ - $.ajax({ - url: '/equip/pvreEditModal', - type: 'GET', - dataType:"html", - success: function(html){ - $("#pvreEditModalContent").empty().append(html); - $("#pvreEditModal").modal('show'); - $("#useDt").datepicker({ - format: "mm-dd", - language: "ko" - }); - $('#detailSelf').hide(); - }, - error:function(){ - - } - }); -}) - -$(document).on('click', '#saveUse', function (){ - - if(confirm("저장하시겠습니까?")){ - document.getElementById("mgtOrgan").disabled = false; - contentFade("in"); - const formData = new FormData($("#useFm")[0]); - $.ajax({ - type : 'POST', - data : formData, - url : "/equip/saveUse", - processData: false, - contentType: false, - success : function(result) { - alert("저장되었습니다."); - contentFade("out"); - location.reload(); - }, - error : function(xhr, status) { - alert("저장에 실패하였습니다.") - contentFade("out"); - } - }) - } -}) - -$(document).on('change', '#detailType', function (){ - if($(this).val() == 'USE007'){ - $('#detailSelf').show(); - }else{ - $('#detailSelf').hide(); - $('#detailSelf').val(''); - } - - -}); \ No newline at end of file diff --git a/src/main/resources/static/js/equip/use.js b/src/main/resources/static/js/equip/use.js new file mode 100644 index 00000000..302d8264 --- /dev/null +++ b/src/main/resources/static/js/equip/use.js @@ -0,0 +1,271 @@ +$(function(){ + $("#dateSelectorDiv").datepicker({ + format: "yyyy-mm-dd", + language: "ko" + }); +}) + +$(document).on('click', '#addPvre', function (){ + const useType = "PVRE"; + showEditModal(useType); +}) + +$(document).on('click', '#addQir', function (){ + const useType = "QIR"; + showEditModal(useType); +}) + +function showEditModal(useType){ + $.ajax({ + url: '/equip/useEditModal', + data: {useType: useType}, + type: 'GET', + dataType:"html", + success: function(html){ + $("#useEditModalContent").empty().append(html); + $("#useEditModal").modal('show'); + $("#useDt").datepicker({ + format: "yyyy-mm-dd", + language: "ko" + }); + $('#detailSelf').hide(); + }, + error:function(){ + + } + }); +} + +$(document).on('click', '#saveUse', function (){ + if($('#mgtOrgan').val() == ""){ + alert("사용관서를 선택해주세요."); + $('#mgtOrgan').focus(); + return false; + } + if(confirm("저장하시겠습니까?")){ + document.getElementById("mgtOrgan").disabled = false; + contentFade("in"); + const formData = new FormData($("#useFm")[0]); + $.ajax({ + type : 'POST', + data : formData, + url : "/equip/saveUse", + processData: false, + contentType: false, + success : function(result) { + alert("저장되었습니다."); + contentFade("out"); + location.reload(); + }, + error : function(xhr, status) { + alert("저장에 실패하였습니다.") + contentFade("out"); + } + }) + } +}) + +$(document).on('change', '#detailType', function (){ + if($(this).val() == 'PVREUSE007' || $(this).val() == 'QIRUSE006'){ + $('#detailSelf').show(); + }else{ + $('#detailSelf').hide(); + $('#detailSelf').val(''); + } +}); + +$(document).on('click', '.useTr', function (event){ + const target = event.target; + if(!(target.className === "useChk" ||$(target).parents("td").length>0)){ + const useNo = $(target).parent('tr').data("useno"); + const useType = $(target).parent('tr').data("usetype"); + const mgtOrgan = $(target).parent('tr').data("mgtorgan"); + showMdifyModal(useNo,useType,mgtOrgan); + } +}); + +function showMdifyModal(useNo,useType,mgtOrgan){ + $.ajax({ + url: '/equip/useModifyModal', + data: {useNo: useNo, + useType: useType, + mgtOrgan: mgtOrgan}, + type: 'GET', + dataType:"html", + success: function(html){ + $("#useEditModalContent").empty().append(html); + $("#useEditModal").modal('show'); + $("#mUseDt").datepicker({ + format: "yyyy-mm-dd", + language: "ko" + }); + if($('#mDetailType').val() != 'PVREUSE007' && $('#mDetailType').val() != 'QIRUSE006'){ + $('#mDetailSelf').hide(); + }else{ + $('#mDetailSelf').show(); + } + }, + error:function(){ + + } + }); +} + +$(document).on('change', '#mDetailType', function (){ + if($(this).val() == 'PVREUSE007' || $(this).val() == 'QIRUSE006'){ + $('#mDetailSelf').show(); + }else{ + $('#mDetailSelf').hide(); + $('#mDetailSelf').val(''); + } +}); + +$(document).on('click', '#updateUse', function (){ + + if(confirm("수정하시겠습니까?")){ + document.getElementById("mMgtOrgan").disabled = false; + contentFade("in"); + const formData = new FormData($("#useUpdateFm")[0]); + $.ajax({ + type : 'POST', + data : formData, + url : "/equip/updateUse", + processData: false, + contentType: false, + success : function(data) { + alert("수정되었습니다."); + contentFade("out"); + showMdifyModal(data.useNo,data.useType,data.mgtOrgan); + }, + error : function(xhr, status) { + alert("수정에 실패하였습니다.") + contentFade("out"); + } + }) + } +}) + +$(document).on('click', '#historyBtn', function (){ + if($('input:checkbox[name=useChk]:checked').length < 1){ + alert("게시물을 선택해주세요") + return false; + } + if($('input:checkbox[name=useChk]:checked').length > 1){ + alert("한개만 선택해주세요") + return false; + } + const target = $('input:checkbox[name=useChk]:checked'); + const useNo = $(target).parent().parent('tr').data("useno"); + const useType = $(target).parent().parent('tr').data("usetype"); + const mgtOrgan = $(target).parent().parent('tr').data("mgtorgan"); + $.ajax({ + url: '/equip/useHistory', + data: {useNo: useNo, + useType: useType, + mgtOrgan: mgtOrgan}, + type: 'GET', + dataType:"html", + success: function(html){ + $("#useEditModalContent").empty().append(html); + $("#useEditModal").modal('show'); + $('#vDetailSelf').hide(); + }, + error:function(){ + + } + }); +}) + +$(document).on('click', '.historyTr', function (event){ + const target = event.target; + $(this).find('.hisChk').prop('checked',true) + if($(this).find('.hisChk').prop('checked')){ + $('.hisChk').prop('checked',false); + $(this).find('.hisChk').prop('checked',true) + } + $.ajax({ + url: '/equip/HistoryView', + data: { + useNo: $(target).parents('tr').data("useno"), + versionNo : Number($(target).parents('tr').data("verno")), + useType : $(target).parents('tr').data("usetype"), + mgtOrgan : $(target).parents('tr').data("mgtorgan") + }, + type: 'GET', + dataType:"json", + success: function(data){ + $('#vSosok').val(data.sosok); + $('#vUseDt').val(data.useDt); + $('#vDetailType').val(data.detailTypeName); + if(data.detailType != 'PVREUSE007' && data.detailType != 'QIRUSE006'){ + $('#vDetailSelf').hide(); + $('#vDetailSelf').val(''); + }else{ + $('#vDetailSelf').show(); + $('#vDetailSelf').val(data.detailSelf); + } + $('#vCnt').val(data.peopleCnt); + $('#vDescription').val(data.description); + }, + error:function(){ + + } + }); +}) + +$(document).on('click', '#deleteUse', function (){ + if($('input:checkbox[name=useChk]:checked').length < 1){ + alert("삭제할 게시물을 선택해주세요") + return false; + } + if(confirm("선택한 대상을 삭제처리 하시겠습니까?")){ + const checkArr = []; + $('input:checkbox[name=useChk]:checked').each(function (idx, el){ + checkArr.push({}); + const target = $(el); + checkArr[idx].useNo = target.parents('tr').data("useno"); + checkArr[idx].mgtOrgan = target.parents('tr').data("mgtorgan"); + checkArr[idx].useType = target.parents('tr').data("usetype"); + }) + deleteUse(checkArr); + } +}) + +function deleteUse(checkArr){ + $.ajax({ + type : 'POST', + url : "/equip/useDelete", + data : JSON.stringify(checkArr), + contentType: 'application/json', + beforeSend: function (xhr){ + xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val()); + }, + success : function() { + alert("삭제처리 되었습니다."); + location.reload(); + }, + error : function(xhr, status) { + alert("삭제처리에 실패하였습니다"); + } + }) +} + +$(document).on('click', '#goExcel', function (){ + if(confirm("엑셀로 다운로드 하시겠습니까?")){ + $('input[name=excel]').val('Y'); + $('#searchFm').submit(); + $('input[name=excel]').val(''); + }else{ + false; + } +}) + +$(document).ready( function() { + $('#chk-all').click( function() { + $('.useCheckBox').prop('checked',this.checked); + }); +}); + +$(document).on('click', '#closeModal', function (){ + location.reload(); +}) \ No newline at end of file diff --git a/src/main/resources/templates/equip/equipEditModal.html b/src/main/resources/templates/equip/equipEditModal.html index dd338322..5688a163 100644 --- a/src/main/resources/templates/equip/equipEditModal.html +++ b/src/main/resources/templates/equip/equipEditModal.html @@ -1,6 +1,5 @@ - - \ No newline at end of file diff --git a/src/main/resources/templates/equip/equipModifyModal.html b/src/main/resources/templates/equip/equipModifyModal.html index 9177487f..f725c293 100644 --- a/src/main/resources/templates/equip/equipModifyModal.html +++ b/src/main/resources/templates/equip/equipModifyModal.html @@ -1,6 +1,5 @@ - + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/equip/pvreEditModal.html b/src/main/resources/templates/equip/useEditModal.html similarity index 82% rename from src/main/resources/templates/equip/pvreEditModal.html rename to src/main/resources/templates/equip/useEditModal.html index c591fdbe..ce7a03d6 100644 --- a/src/main/resources/templates/equip/pvreEditModal.html +++ b/src/main/resources/templates/equip/useEditModal.html @@ -3,10 +3,10 @@