diff --git a/src/main/java/com/dbnt/faisp/config/BaseService.java b/src/main/java/com/dbnt/faisp/config/BaseService.java new file mode 100644 index 00000000..60fc895a --- /dev/null +++ b/src/main/java/com/dbnt/faisp/config/BaseService.java @@ -0,0 +1,29 @@ +package com.dbnt.faisp.config; + +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +import java.io.File; + +@Service +@RequiredArgsConstructor +public class BaseService { + + @Value("${spring.servlet.multipart.location}") + protected String locationPath; + + protected String calculationSize(double fileSize){ + String[] units = {"bytes", "KB", "MB", "GB", "TB", "PB"}; + double unitSelector = Math.floor(Math.log(fileSize)/Math.log(1024)); + if(fileSize>0){ + return Math.round((fileSize/Math.pow(1024, unitSelector))*100)/100d+" "+units[(int)unitSelector]; + }else{ + return ""; + } + } + + public void deleteStoredFile(File deleteFile){ + deleteFile.delete(); + } +} diff --git a/src/main/java/com/dbnt/faisp/config/FileController.java b/src/main/java/com/dbnt/faisp/config/FileController.java new file mode 100644 index 00000000..d26f0179 --- /dev/null +++ b/src/main/java/com/dbnt/faisp/config/FileController.java @@ -0,0 +1,100 @@ +package com.dbnt.faisp.config; + +import com.dbnt.faisp.fpiMgt.monthPlan.service.MonthPlanService; +import com.dbnt.faisp.userInfo.model.UserInfo; +import lombok.RequiredArgsConstructor; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.util.FileCopyUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.*; +import java.net.URLEncoder; + +@RestController +@RequiredArgsConstructor +public class FileController { + + private final MonthPlanService monthPlanService; + + @GetMapping("/file/fileDownload") + public void fileDownload(HttpServletRequest request, + HttpServletResponse response, + String board, + Integer parentKey, + Integer fileSeq) { + FileInfo downloadFile = null; + switch (board){ + case "monthPlan": + downloadFile = monthPlanService.selectPlanFile(parentKey, fileSeq); + break; + } + + BufferedInputStream in; + BufferedOutputStream out; + try { + File file = new File(downloadFile.getSavePath(), downloadFile.getConvNm()); + + setDisposition(downloadFile.getFullName(), request, response); + in = new BufferedInputStream(new FileInputStream(file)); + out = new BufferedOutputStream(response.getOutputStream()); + FileCopyUtils.copy(in, out); + out.flush(); + if(out!=null) out.close(); + if(in!=null )in.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + private void setDisposition(String filename, HttpServletRequest request, HttpServletResponse response) throws IOException { + String browser = getBrowser(request); + + String dispositionPrefix = "attachment; filename="; + String encodedFilename = null; + + if (browser.equals("MSIE")) { + encodedFilename = URLEncoder.encode(filename, "UTF-8").replaceAll("\\+", "%20"); + } else if (browser.equals("Trident")) { // IE11 문자열 깨짐 방지 + encodedFilename = URLEncoder.encode(filename, "UTF-8").replaceAll("\\+", "%20"); + } else if (browser.equals("Firefox")) { + encodedFilename = "\"" + new String(filename.getBytes("UTF-8"), "8859_1") + "\""; + } else if (browser.equals("Opera")) { + encodedFilename = "\"" + new String(filename.getBytes("UTF-8"), "8859_1") + "\""; + } else if (browser.equals("Chrome")) { + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < filename.length(); i++) { + char c = filename.charAt(i); + if (c > '~') { + sb.append(URLEncoder.encode("" + c, "UTF-8")); + } else { + sb.append(c); + } + } + encodedFilename = sb.toString(); + } else { + throw new IOException("Not supported browser"); + } + + response.setHeader("Content-Disposition", dispositionPrefix + encodedFilename); + + if ("Opera".equals(browser)) { + response.setContentType("application/octet-stream;charset=UTF-8"); + } + } + + private String getBrowser(HttpServletRequest request) { + String header = request.getHeader("User-Agent"); + if (header.indexOf("MSIE") > -1) { + return "MSIE"; + } else if (header.indexOf("Trident") > -1) { // IE11 문자열 깨짐 방지 + return "Trident"; + } else if (header.indexOf("Chrome") > -1) { + return "Chrome"; + } else if (header.indexOf("Opera") > -1) { + return "Opera"; + } + return "Firefox"; + } +} diff --git a/src/main/java/com/dbnt/faisp/config/FileInfo.java b/src/main/java/com/dbnt/faisp/config/FileInfo.java new file mode 100644 index 00000000..43fc9b12 --- /dev/null +++ b/src/main/java/com/dbnt/faisp/config/FileInfo.java @@ -0,0 +1,25 @@ +package com.dbnt.faisp.config; + +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import javax.persistence.Column; +import javax.persistence.Transient; +import java.util.List; + +@Getter +@Setter +@NoArgsConstructor +public class FileInfo { + + private String origNm; + private String convNm; + private String fileExtn; + private String fileSize; + private String savePath; + + public String getFullName(){ + return getOrigNm()+"."+getFileExtn(); + } +} diff --git a/src/main/java/com/dbnt/faisp/fpiMgt/FpiMgtController.java b/src/main/java/com/dbnt/faisp/fpiMgt/FpiMgtController.java index 0f1ae45c..0bc0391e 100644 --- a/src/main/java/com/dbnt/faisp/fpiMgt/FpiMgtController.java +++ b/src/main/java/com/dbnt/faisp/fpiMgt/FpiMgtController.java @@ -6,6 +6,7 @@ import com.dbnt.faisp.userInfo.model.UserInfo; import lombok.RequiredArgsConstructor; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.servlet.ModelAndView; import java.time.LocalDateTime; @@ -55,7 +56,10 @@ public class FpiMgtController { // 외사경찰견문관리 @PostMapping("/savePlan") public Integer savePlan(BoardPlan boardPlan, @RequestParam(value = "planInfos", required = false) List planInfos, - @RequestParam(value = "detailPlanInfos", required = false)List detailPlanInfos){ - return monthPlanService.saveBoardPlan(boardPlan, planInfos, detailPlanInfos); + @RequestParam(value = "detailPlanInfos", required = false)List detailPlanInfos, + MultipartHttpServletRequest request, + @RequestParam(value = "fileSeq", required = false) List deleteFileSeq){ + boardPlan.setMultipartFileList(request.getMultiFileMap().get("uploadFiles")); + return monthPlanService.saveBoardPlan(boardPlan, planInfos, detailPlanInfos, deleteFileSeq); } } diff --git a/src/main/java/com/dbnt/faisp/fpiMgt/monthPlan/model/BoardPlan.java b/src/main/java/com/dbnt/faisp/fpiMgt/monthPlan/model/BoardPlan.java index 83fc72e2..476ee286 100644 --- a/src/main/java/com/dbnt/faisp/fpiMgt/monthPlan/model/BoardPlan.java +++ b/src/main/java/com/dbnt/faisp/fpiMgt/monthPlan/model/BoardPlan.java @@ -7,6 +7,7 @@ import lombok.Setter; import org.hibernate.annotations.DynamicInsert; import org.hibernate.annotations.DynamicUpdate; import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.web.multipart.MultipartFile; import javax.persistence.*; import java.time.LocalDate; @@ -52,9 +53,13 @@ public class BoardPlan extends BaseModel { @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm") private LocalDateTime wrtDt; + @Transient + private Integer fileCnt; @Transient private List mainInfoList; @Transient private List fileList; + @Transient + private List multipartFileList; } diff --git a/src/main/java/com/dbnt/faisp/fpiMgt/monthPlan/model/PlanFile.java b/src/main/java/com/dbnt/faisp/fpiMgt/monthPlan/model/PlanFile.java index a412f390..6e0bc846 100644 --- a/src/main/java/com/dbnt/faisp/fpiMgt/monthPlan/model/PlanFile.java +++ b/src/main/java/com/dbnt/faisp/fpiMgt/monthPlan/model/PlanFile.java @@ -1,5 +1,6 @@ package com.dbnt.faisp.fpiMgt.monthPlan.model; +import com.dbnt.faisp.config.FileInfo; import lombok.*; import org.hibernate.annotations.DynamicInsert; import org.hibernate.annotations.DynamicUpdate; @@ -15,7 +16,7 @@ import java.io.Serializable; @DynamicUpdate @Table(name = "plan_file") @IdClass(PlanFile.PlanFileId.class) -public class PlanFile{ +public class PlanFile extends FileInfo { @Id @Column(name = "plan_key") private Integer planKey; @@ -29,7 +30,7 @@ public class PlanFile{ @Column(name = "file_extn") private String fileExtn; @Column(name = "file_size") - private Integer fileSize; + private String fileSize; @Column(name = "save_path") private String savePath; diff --git a/src/main/java/com/dbnt/faisp/fpiMgt/monthPlan/repository/PlanFileRepository.java b/src/main/java/com/dbnt/faisp/fpiMgt/monthPlan/repository/PlanFileRepository.java index 908e11bf..ad6796a6 100644 --- a/src/main/java/com/dbnt/faisp/fpiMgt/monthPlan/repository/PlanFileRepository.java +++ b/src/main/java/com/dbnt/faisp/fpiMgt/monthPlan/repository/PlanFileRepository.java @@ -4,8 +4,10 @@ import com.dbnt.faisp.fpiMgt.monthPlan.model.PlanFile; import org.springframework.data.jpa.repository.JpaRepository; import java.util.List; +import java.util.Optional; public interface PlanFileRepository extends JpaRepository { List findByPlanKey(Integer planKey); + Optional findByPlanKeyOrderByFileSeqDesc(Integer planKey); } diff --git a/src/main/java/com/dbnt/faisp/fpiMgt/monthPlan/service/MonthPlanService.java b/src/main/java/com/dbnt/faisp/fpiMgt/monthPlan/service/MonthPlanService.java index 89b9506c..98d17a31 100644 --- a/src/main/java/com/dbnt/faisp/fpiMgt/monthPlan/service/MonthPlanService.java +++ b/src/main/java/com/dbnt/faisp/fpiMgt/monthPlan/service/MonthPlanService.java @@ -1,6 +1,8 @@ package com.dbnt.faisp.fpiMgt.monthPlan.service; +import com.dbnt.faisp.config.BaseService; +import com.dbnt.faisp.config.FileInfo; import com.dbnt.faisp.fpiMgt.monthPlan.mapper.MonthPlanMapper; import com.dbnt.faisp.fpiMgt.monthPlan.model.BoardPlan; import com.dbnt.faisp.fpiMgt.monthPlan.model.PlanFile; @@ -9,15 +11,20 @@ import com.dbnt.faisp.fpiMgt.monthPlan.repository.BoardPlanRepository; import com.dbnt.faisp.fpiMgt.monthPlan.repository.PlanFileRepository; import com.dbnt.faisp.fpiMgt.monthPlan.repository.PlanMainInfoRepository; import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; import javax.persistence.Transient; +import java.io.File; +import java.io.IOException; import java.util.List; +import java.util.UUID; @Service @RequiredArgsConstructor -public class MonthPlanService { +public class MonthPlanService extends BaseService { private final BoardPlanRepository boardPlanRepository; private final PlanFileRepository planFileRepository; private final PlanMainInfoRepository planMainInfoRepository; @@ -25,16 +32,24 @@ public class MonthPlanService { public BoardPlan selectBoardPlan(Integer planKey) { BoardPlan savedPlan = boardPlanRepository.findById(planKey).orElse(null); - savedPlan.setFileList(planFileRepository.findByPlanKey(planKey)); - savedPlan.setMainInfoList(planMainInfoRepository.findByPlanKey(planKey)); + if (savedPlan != null) { + savedPlan.setFileList(planFileRepository.findByPlanKey(planKey)); + savedPlan.setMainInfoList(planMainInfoRepository.findByPlanKey(planKey)); + } return savedPlan; } @Transactional - public Integer saveBoardPlan(BoardPlan boardPlan, List planInfos, List detailPlanInfos) { + public Integer saveBoardPlan(BoardPlan boardPlan, List planInfos, List detailPlanInfos, List deleteFileSeq) { Integer planKey = boardPlanRepository.save(boardPlan).getPlanKey(); Integer infoSeq = savePlanMainInfos(planKey,0, "S", planInfos);//요약 summery savePlanMainInfos(planKey, infoSeq, "D", detailPlanInfos);//상세 detail + if(deleteFileSeq.size()>0){ + deletePlanFile(planKey, deleteFileSeq); + } + if(boardPlan.getMultipartFileList()!=null){ + saveUploadFiles(planKey, boardPlan.getMultipartFileList()); + } return planKey; } @@ -57,4 +72,57 @@ public class MonthPlanService { public Integer selectBoardPlanListCnt(BoardPlan boardPlan) { return monthPlanMapper.selectBoardPlanListCnt(boardPlan); } + + private void saveUploadFiles(Integer planKey, List multipartFileList){ + PlanFile lastFileInfo = planFileRepository.findByPlanKeyOrderByFileSeqDesc(planKey).orElse(null); + int fileSeq = lastFileInfo==null?1:(lastFileInfo.getFileSeq()+1); + for(MultipartFile file : multipartFileList){ + String saveName = UUID.randomUUID().toString(); + String path = locationPath+File.separator+"monthPlan"+File.separator; + + File saveFile = new File(path+File.separator+saveName); + if(file.getSize()!=0){ // 저장될 파일 확인 + if(!saveFile.exists()){ // 저장될 경로 확인 + if(saveFile.getParentFile().mkdirs()){ + try{ + saveFile.createNewFile(); + }catch (IOException e){ + e.printStackTrace(); + } + } + } + try { + file.transferTo(saveFile); + }catch (IllegalStateException | IOException e){ + e.printStackTrace(); + } + } + + String originalFilename = file.getOriginalFilename(); + int extnIdx = originalFilename.lastIndexOf("."); + PlanFile fileInfo = new PlanFile(); + fileInfo.setPlanKey(planKey); + fileInfo.setFileSeq(fileSeq++); + fileInfo.setOrigNm(originalFilename.substring(0, extnIdx)); + fileInfo.setFileExtn(originalFilename.substring(extnIdx+1)); + fileInfo.setConvNm(saveName); + fileInfo.setFileSize(calculationSize(file.getSize())); + fileInfo.setSavePath(path); + planFileRepository.save(fileInfo); + } + } + + public void deletePlanFile(Integer planKey, List deleteFileSeq) { + List planFileList = planFileRepository.findByPlanKey(planKey); + for(PlanFile file: planFileList){ + if(deleteFileSeq.contains(file.getFileSeq())){ + deleteStoredFile(new File(file.getSavePath(), file.getConvNm())); + planFileRepository.delete(file); + } + } + } + + public FileInfo selectPlanFile(Integer parentKey, Integer fileSeq) { + return planFileRepository.findById(new PlanFile.PlanFileId(parentKey, fileSeq)).orElse(null); + } } diff --git a/src/main/resources/mybatisMapper/MonthPlanMapper.xml b/src/main/resources/mybatisMapper/MonthPlanMapper.xml index b114d3ed..a0ff1752 100644 --- a/src/main/resources/mybatisMapper/MonthPlanMapper.xml +++ b/src/main/resources/mybatisMapper/MonthPlanMapper.xml @@ -14,10 +14,10 @@ a.wrt_organ, a.wrt_nm, a.wrt_dt, - b.file_seq + b.fileCnt from board_plan a left outer join (select plan_key, - max(file_seq) as file_seq + count(file_seq) as fileCnt from plan_file group by plan_key) b on a.plan_key = b.plan_key diff --git a/src/main/resources/static/js/common.js b/src/main/resources/static/js/common.js index 25c3d83b..d0d011c4 100644 --- a/src/main/resources/static/js/common.js +++ b/src/main/resources/static/js/common.js @@ -45,4 +45,47 @@ $(document).on('mouseenter', '.secondMenuLink', function (event){ $(document).on('mouseleave', '.menuDiv', function (){ $(".secondMenu").hide(); $(".thirdMenu").hide(); +}) + +$(document).on('change', '#fileInputer', function (){ + for(const file of this.files){ + setFileDiv(file, files.push(file)); + } + this.value = null; +}) + +function byteCalculation(size) { + const bytes = parseInt(size); + const s = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB']; + const e = Math.floor(Math.log(bytes)/Math.log(1024)); + + if(e === "-Infinity") return "0 "+s[0]; + else return (bytes/Math.pow(1024, Math.floor(e))).toFixed(2)+" "+s[e]; + +} + +$(document).on('click', '.fileDelete', function (){ + const target = $(this); + files[Number(target.attr("data-fileidx"))].isDelete = true; + target.parent().remove(); + const uploadDiv = $("#uploadDiv"); + if(uploadDiv.children().length === 0){ + uploadDiv.append("
파일을 업로드 해주세요."); + } +}) +$(document).on('click', '.uploadedFileDelete', function (){ + const target = $(this).parent().find("span")[0]; + if(target.className===""){ + target.className = "text-decoration-line-through"; + }else{ + target.className = ""; + } +}) + +$(document).on('click', '.fileDownLink', function (){ + let url = "/file/fileDownload?" + url += "board="+$(this).attr("data-board"); + url += "&parentKey="+Number($("#viewModalPlanKey").val()); + url += "&fileSeq="+$(this).attr("data-fileseq"); + window.open(encodeURI(url)); }) \ No newline at end of file diff --git a/src/main/resources/static/js/igActivities/fpiMgt/monthPlan.js b/src/main/resources/static/js/igActivities/fpiMgt/monthPlan.js index dab4e092..0d62a2aa 100644 --- a/src/main/resources/static/js/igActivities/fpiMgt/monthPlan.js +++ b/src/main/resources/static/js/igActivities/fpiMgt/monthPlan.js @@ -1,108 +1,184 @@ +let files = []; $(document).on('click', '#addPlanBtn', function (){ - getEditModal(null) + getEditModal(null) }) $(document).on('click', '.planTr', function (){ - $.ajax({ - url: '/fpiMgt/planViewModal', - data: {planKey: Number($(this).find(".planKey").val())}, - type: 'GET', - dataType:"html", - success: function(html){ - $("#planViewBody").empty().append(html) - $("#planViewModal").modal('show'); - }, - error:function(){ - - } - }); + getViewModal(Number($(this).find(".planKey").val())); }) $(document).on('click', '#editPlanBtn', function (){ - $("#planViewModal").modal('hide'); - getEditModal(Number($("#planViewBody").find("[name='planKey']").val())); + $("#planViewModal").modal('hide'); + getEditModal(Number($("#planViewBody").find("[name='planKey']").val())); }) $(document).on('click', '#planAddBtn', function (){ - $("#planDiv").append("") + $("#planDiv").append("") }) $(document).on('click', '#detailPlanAddBtn', function (){ - const detailPlanDiv = $("#detailPlanDiv"); - detailPlanDiv.append(""); - const lastAppendTextarea = detailPlanDiv.children()[detailPlanDiv.children().length-1]; - $(lastAppendTextarea).summernote({ + 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('S') +}) +$(document).on('click', '#saveTempBtn', function (){ + savePlan('T') +}) + +function getViewModal(planKey){ + $.ajax({ + url: '/fpiMgt/planViewModal', + data: {planKey: planKey}, + type: 'GET', + dataType:"html", + success: function(html){ + $("#planViewBody").empty().append(html) + $("#planViewModal").modal('show'); + }, + error:function(){ + + } + }); +} + +function getEditModal(planKey){ + $.ajax({ + url: '/fpiMgt/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" + }); + $("[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']] + ['style', ['style']], + ['font', ['bold', 'underline', 'clear']], + ['color', ['color']], + ['para', ['ul', 'ol', 'paragraph']], + ['table', ['table']] ] - }); -}) + }); + setUploadDiv(); + }, + error:function(){ -$(document).on('click', '#savePlanBtn', function (){ - savePlan('S') -}) -$(document).on('click', '#saveTempBtn', function (){ - savePlan('T') -}) - -function getEditModal(planKey){ - $.ajax({ - url: '/fpiMgt/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" - }); - $("[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']] - ] - }); + } + }); +} +function setUploadDiv(){ + files = []; + $("#uploadDiv").on("dragenter", function(e) { + // $(this).addClass('drag-over'); + }).on("dragleave", function(e) { + // $(this).removeClass('drag-over'); + }).on("dragover", function(e) { + e.stopPropagation(); + e.preventDefault(); + }).on('drop', function(e) { + e.preventDefault(); + // $(this).removeClass('drag-over'); + for(const file of e.originalEvent.dataTransfer.files){ + setFileDiv(file, files.push(file)); + } + }).on('click', function (e){ + if(e.target.className.indexOf("ileDelete")<0){ + $("#fileInputer").click(); + } + }); +} +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 : "/fpiMgt/savePlan", + processData: false, + contentType: false, + success : function(result) { + alert("저장되었습니다."); + contentFade("out"); + $("#planEditModal").modal('hide'); + getViewModal(result); }, - error:function(){ - + error : function(xhr, status) { + alert("저장에 실패하였습니다.") + contentFade("out"); } - }); + }) + } + } } -function savePlan(planState){ - if(confirm("저장하시겠습니까?")){ - $("#planState").val(planState); - contentFade("in"); - const formData = new FormData($("#planEditForm")[0]); - $.ajax({ - type : 'POST', - data : formData, - url : "/fpiMgt/savePlan", - processData: false, - contentType: false, - success : function(result) { - debugger - contentFade("out"); - }, - error : function(xhr, status) { - alert("저장에 실패하였습니다.") - contentFade("out"); - } - }) +function setFileDiv(file, idx){ + const uploadDiv = $("#uploadDiv"); + if($(".uploadedFileDelete").length===0 && $(".fileDelete").length === 0){ + uploadDiv.empty(); + } + let fileInfo = "
"; + fileInfo += file.name+" "+byteCalculation(file.size)+" "; + fileInfo += "삭제"; + fileInfo += "
"; + uploadDiv.append(fileInfo); +} + +function contentCheck(){ + let flag = true; + if(!$("#contentTitle").val()){ + alert("제목을 입력해주세요.") + flag = false; + } + if(!$("#planDt").val()){ + alert("시행일자를 입력해주세요.") + flag = false; + } + let totalSize = 0; + for(const file of files) { + if(!file.isDelete){ + totalSize+=file.size; + if(file.size>209715200){ + alert("파일당 사이즈는 200MB을 넘길 수 없습니다.") + flag = false; + } } + } + if(totalSize>524288000){ + alert("첨부파일의 용량 합은 500MB를 넘길 수 없습니다.") + flag = false; + } + return flag; } \ No newline at end of file diff --git a/src/main/resources/templates/igActivities/fpiMgt/monthPlan/apprvCommitTab.html b/src/main/resources/templates/igActivities/fpiMgt/monthPlan/apprvCommitTab.html new file mode 100644 index 00000000..d6a0066d --- /dev/null +++ b/src/main/resources/templates/igActivities/fpiMgt/monthPlan/apprvCommitTab.html @@ -0,0 +1,94 @@ + + +
+ +
+
+ +
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
제목시행일자작성자작성일시첨부파일상태
계장결재계장반려부장결재부장반려임시저장결재대기
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ \ No newline at end of file diff --git a/src/main/resources/templates/igActivities/fpiMgt/monthPlan/apprvStayTab.html b/src/main/resources/templates/igActivities/fpiMgt/monthPlan/apprvStayTab.html new file mode 100644 index 00000000..d6a0066d --- /dev/null +++ b/src/main/resources/templates/igActivities/fpiMgt/monthPlan/apprvStayTab.html @@ -0,0 +1,94 @@ + + +
+ +
+
+ +
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
제목시행일자작성자작성일시첨부파일상태
계장결재계장반려부장결재부장반려임시저장결재대기
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ \ No newline at end of file diff --git a/src/main/resources/templates/igActivities/fpiMgt/monthPlan/monthPlan.html b/src/main/resources/templates/igActivities/fpiMgt/monthPlan/monthPlan.html index 6acd770f..25f773ae 100644 --- a/src/main/resources/templates/igActivities/fpiMgt/monthPlan/monthPlan.html +++ b/src/main/resources/templates/igActivities/fpiMgt/monthPlan/monthPlan.html @@ -70,7 +70,7 @@ - + 계장결재 계장반려 부장결재 @@ -123,14 +123,14 @@