Files
wace_plm/WebContent/WEB-INF/view/quality/ecrResultFormPopUp.jsp

471 lines
14 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page import="com.pms.common.utils.*"%>
<%@ page import="java.util.*" %>
<%@include file= "/init_new.jsp" %>
<%
String menuObjId = request.getParameter("menuObjId");
String actionType = CommonUtils.checkNull(request.getParameter("actionType"));
// 뷰 모드인지 판단
boolean isViewMode = "view".equals(actionType);
String menuName = isViewMode ? "ECR 결과조회" : CommonUtils.getMenuName(menuObjId, "ECR 결과등록");
Map info = (Map)request.getAttribute("info");
if(info == null) info = new HashMap();
String objId = CommonUtils.checkNull(info.get("objid"));
// 오늘 날짜
String today = new java.text.SimpleDateFormat("yyyy-MM-dd").format(new java.util.Date());
String completeDate = CommonUtils.checkNull(info.get("complete_date"));
if(completeDate.isEmpty()) completeDate = today;
// 조치자 - 기본값 로그인 사용자
String actionUserId = CommonUtils.checkNull(info.get("action_user_id"));
if(actionUserId.isEmpty()) actionUserId = connectUserId;
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><%=Constants.SYSTEM_NAME%></title>
<style>
body { min-height: auto !important; }
.two_column_container {
display: flex;
gap: 15px;
padding: 10px;
}
.two_column_container > div {
flex: 1;
}
.two_column_container .pmsPopuptable tr {
height: 38px;
}
</style>
</head>
<script type="text/javascript">
var isViewMode = <%=isViewMode%>;
$(document).ready(function(){
fnc_datepick();
$('.select2').select2();
// 기존 값 선택
var savedActionUserId = "<%=actionUserId%>";
if(savedActionUserId) $("#ACTION_USER_ID").val(savedActionUserId).trigger('change');
// 뷰 모드일 경우 입력 필드 비활성화
if(isViewMode){
$("#form1 input, #form1 textarea, #form1 select").prop("disabled", true);
$("#btnSave, #btnUpload, #btnImgUpload, #file1, #imgFile1").hide();
$(".delete_btn").parent().hide();
} else {
// 첨부파일 드래그앤드랍 설정
fnc_setFileDropZone("srDropZone", "<%=objId%>", "ECR_RESULT", "ECR결과첨부", "srAreaDraw", false, null, null, null, "");
}
srAreaDraw();
imgAreaDraw();
// 파일 업로드 버튼
$("#btnUpload").click(function(){
var files = $("#file1")[0].files;
if(files.length > 0){
fnc_fileMultiUpload(files, null, "<%=objId%>", "ECR_RESULT", "ECR결과첨부", null, "srAreaDraw", null, "");
$("#file1").val("");
}else{
Swal.fire("선택된 파일이 없습니다.");
}
});
// 이미지 업로드 버튼
$("#btnImgUpload").click(function(){
var files = $("#imgFile1")[0].files;
if(files.length > 0){
// 이미지 파일 확장자 검사
var allowedExts = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'];
for(var i = 0; i < files.length; i++){
var ext = files[i].name.split('.').pop().toLowerCase();
if(allowedExts.indexOf(ext) < 0){
Swal.fire("이미지 파일만 업로드 가능합니다. (jpg, jpeg, png, gif, bmp, webp)");
return;
}
}
fnc_fileMultiUpload(files, null, "<%=objId%>", "ECR_RESULT_IMAGE", "ECR결과이미지", null, "imgAreaDraw", null, "");
$("#imgFile1").val("");
}else{
Swal.fire("선택된 파일이 없습니다.");
}
});
// 저장
$("#btnSave").click(function(){
fn_save();
});
// 닫기
$("#btnClose").click(function(){
window.close();
});
});
// 첨부파일 목록 새로고침
function srAreaDraw(){
fn_fileCallback("sr", "ECR_RESULT");
}
// 이미지 목록 새로고침
function imgAreaDraw(){
fn_imageCallback("img", "ECR_RESULT_IMAGE");
}
// 이미지 목록 조회
function fn_imageCallback(areaId, fileType){
$.ajax({
url: "/common/getFileList.do",
type: "POST",
data: {"targetObjId": "<%=objId%>", "docType": fileType},
dataType: "json",
async: false,
success: function(data){
$("#" + areaId + "FileArea").empty();
if(data.length > 0){
$.each(data, function(i){
var imgSrc = "/common/viewImageByObjId.do?objId=" + data[i].OBJID;
var appendHtml = '<div class="image-preview-item" style="display:inline-block; margin:5px; position:relative; text-align:center;">';
appendHtml += '<img src="' + imgSrc + '" onclick="viewImage(\'' + imgSrc + '\')" title="클릭하여 원본보기" style="width:80px; height:80px; object-fit:cover; cursor:pointer; border:1px solid #ddd; border-radius:4px;">';
if(!isViewMode){
appendHtml += '<button type="button" onclick="fn_imageDelete(\'' + data[i].OBJID + '\', event)" title="삭제" style="position:absolute; top:-5px; right:-5px; background:#ff4444; color:white; border:none; border-radius:50%; width:20px; height:20px; cursor:pointer; font-size:12px;">×</button>';
}
appendHtml += '<div style="font-size:10px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:80px;" title="' + data[i].REAL_FILE_NAME + '">' + data[i].REAL_FILE_NAME + '</div>';
appendHtml += '</div>';
$("#" + areaId + "FileArea").append(appendHtml);
});
}else{
$("#" + areaId + "FileArea").append('<div style="color:#999; padding:10px;">등록된 이미지가 없습니다.</div>');
}
}
});
}
// 이미지 원본 보기
function viewImage(imgSrc){
var img = new Image();
img.onload = function(){
var width = Math.min(this.width, 1200);
var height = Math.min(this.height, 800);
window.open(imgSrc, "imageView", "width=" + width + ",height=" + height + ",scrollbars=yes,resizable=yes");
};
img.src = imgSrc;
}
// 이미지 삭제
function fn_imageDelete(fileObjId, event){
if(event){
event.preventDefault();
event.stopPropagation();
}
if(isViewMode) return;
if(confirm("이미지를 삭제하시겠습니까?")){
$.ajax({
url: "/common/deleteFileInfo.do",
type: "POST",
data: {"objId": fileObjId},
dataType: "json",
async: false,
success: function(data){
imgAreaDraw();
}
});
}
}
// 첨부파일 목록 조회
function fn_fileCallback(areaId, fileType){
$.ajax({
url: "/common/getFileList.do",
type: "POST",
data: {"targetObjId": "<%=objId%>", "docType": fileType},
dataType: "json",
async: false,
success: function(data){
$("#" + areaId + "FileArea").empty();
if(data.length > 0){
$.each(data, function(i){
var appendText = "";
var fileExt = data[i].UPPER_FILE_EXT;
appendText += "<tr>";
appendText += "<td>" + (i + 1) + "</td>";
if(fileExt == 'PDF'){
appendText += "<td class='align_l'><a href='javascript:fnc_viewPdfFile(\"" + data[i].OBJID + "\")'>&nbsp;&nbsp;" + data[i].REAL_FILE_NAME + "</a>";
}else{
appendText += "<td class='align_l'><a href='javascript:fnc_downloadFile(\"" + data[i].OBJID + "\")'>&nbsp;&nbsp;" + data[i].REAL_FILE_NAME + "</a>";
}
if(!isViewMode){
appendText += "<a href='javascript:fn_fileDelete(\"" + data[i].OBJID + "\")'><div class='delete_btn'></div></a>";
}
appendText += "</td>";
appendText += "<td>" + data[i].REGDATE + "</td>";
appendText += "<td>" + data[i].FILE_SIZE + "</td>";
appendText += "</tr>";
$("#" + areaId + "FileArea").append(appendText);
});
}else{
var appendText = "<tr><td colspan='4'>첨부 파일이 없습니다.</td></tr>";
$("#" + areaId + "FileArea").append(appendText);
}
}
});
}
// PDF 미리보기
function fnc_viewPdfFile(fileObjId){
window.open("/common/downloadFile.do?objId=" + fileObjId, "_blank");
}
// 첨부파일 삭제
function fn_fileDelete(fileObjId){
if(isViewMode) return;
if(confirm("파일을 삭제하시겠습니까?")){
$.ajax({
url: "/common/deleteFileInfo.do",
type: "POST",
data: {"objId": fileObjId},
dataType: "json",
async: false,
success: function(data){
srAreaDraw();
}
});
}
}
function fn_save(){
// 유효성 검사
if(!fnc_valitate("form1")){
return;
}
Swal.fire({
title: '저장하시겠습니까?',
icon: 'question',
showCancelButton: true,
confirmButtonText: '저장',
cancelButtonText: '취소'
}).then((result) => {
if(result.isConfirmed){
$.ajax({
url: "/quality/saveEcrResult.do",
type: "POST",
data: $("#form1").serialize(),
dataType: "json",
success: function(result){
if(result.RESULT == "SUCCESS"){
Swal.fire({
title: '저장되었습니다.',
icon: 'success'
}).then(() => {
if(window.opener && window.opener.fn_search){
window.opener.fn_search();
}
window.close();
});
} else {
Swal.fire({
title: '저장 실패',
text: result.MESSAGE || '저장 중 오류가 발생했습니다.',
icon: 'error'
});
}
},
error: function(xhr, status, error){
Swal.fire({
title: '저장 실패',
text: '서버 통신 오류가 발생했습니다.',
icon: 'error'
});
}
});
}
});
}
</script>
<body>
<form name="form1" id="form1" method="post">
<input type="hidden" name="OBJID" id="OBJID" value="${info.objid}">
<section class="business_staff_popup_min_width">
<div class="plm_menu_name">
<h2>
<span><%=menuName%></span>
</h2>
</div>
<div id="EntirePopupFormWrap">
<div class="two_column_container">
<!-- 왼쪽: ECR 요청 정보 -->
<div>
<div class="form_popup_title">
<span>ECR 요청 정보</span>
</div>
<table class="">
<colgroup>
<col width="90%" />
</colgroup>
<tr>
<td>
<table class="pmsPopuptable">
<colgroup>
<col width="25%" />
<col width="25%" />
<col width="25%" />
<col width="25%" />
</colgroup>
<tr>
<td class="input_title"><label>ECR No</label></td>
<td>${info.ecr_no}</td>
<td class="input_title"><label>요청일</label></td>
<td>${info.request_date}</td>
</tr>
<tr>
<td class="input_title"><label>요청자</label></td>
<td>${info.requester_name}</td>
<td class="input_title"><label>완료요청일</label></td>
<td>${info.due_date}</td>
</tr>
<tr>
<td class="input_title"><label>품번</label></td>
<td>${info.part_no}</td>
<td class="input_title"><label>품명</label></td>
<td>${info.part_name}</td>
</tr>
<tr>
<td class="input_title"><label>조치부서</label></td>
<td colspan="3">${info.action_dept_name}</td>
<!-- <td class="input_title"><label>조치담당자</label></td>
<td>${info.action_manager_name}</td> -->
</tr>
<tr>
<td class="input_title"><label>이슈사항</label></td>
<td colspan="3">
<textarea rows="10" style="width:100%;" readonly>${info.issue_content}</textarea>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<!-- 오른쪽: 조치결과 등록 -->
<div>
<div class="form_popup_title">
<span>조치결과 등록</span>
</div>
<table class="">
<colgroup>
<col width="110%" />
</colgroup>
<tr>
<td>
<table class="pmsPopuptable">
<colgroup>
<col width="25%" />
<col width="25%" />
<col width="25%" />
<col width="25%" />
</colgroup>
<tr>
<td class="input_title"><label>조치자 <span style="color:red;">*</span></label></td>
<td>
<select name="ACTION_USER_ID" id="ACTION_USER_ID" class="select2" required reqTitle="조치자" type="select" style="width:100%;">
<option value="">선택</option>
${code_map.action_user_id}
</select>
</td>
<td class="input_title"><label>완료일 <span style="color:red;">*</span></label></td>
<td>
<input type="text" name="COMPLETE_DATE" id="COMPLETE_DATE" class="date_icon" value="<%=completeDate%>" required reqTitle="완료일">
</td>
</tr>
<tr>
<td class="input_title"><label>조치내용 <span style="color:red;">*</span></label></td>
<td colspan="3">
<textarea name="ACTION_CONTENT" id="ACTION_CONTENT" rows="4" style="width:100%;" required reqTitle="조치내용" type="text">${info.action_content}</textarea>
</td>
</tr>
<tr>
<td class="input_title"><label>이미지</label></td>
<td colspan="3">
<div style="margin-bottom: 5px;">
<input type="file" name="imgFile1" id="imgFile1" multiple accept="image/*" style="width:80%;">
<input type="button" id="btnImgUpload" value="업로드" class="plm_btns">
</div>
<div id="imgFileArea" style="min-height:50px; border:1px dashed #ccc; border-radius:4px; padding:5px; background:#fafafa;">
</div>
</td>
</tr>
<tr>
<td class="input_title"><label>첨부파일</label></td>
<td colspan="3">
<div style="margin-bottom: 5px;">
<input type="file" name="file1" id="file1" multiple style="width:80%;">
<input type="button" id="btnUpload" value="업로드" class="plm_btns">
</div>
<div id="srFileAreaTable" class="spec_data_in_table">
<div style="overflow-y:auto;">
<table class="fileListscrollThead" style="width:100% !important;">
<colgroup>
<col width="30px">
<col width="*">
<col width="80px">
<col width="60px">
</colgroup>
<tr>
<td>No</td>
<td>파일명</td>
<td>등록일</td>
<td>Size</td>
</tr>
</table>
</div>
<div style="max-height: 80px; overflow-y: auto; border-bottom: 1px solid #cacaca;">
<table class="fileListscrollTbody">
<colgroup>
<col width="30px">
<col width="*">
<col width="80px">
<col width="60px">
</colgroup>
<tbody id="srFileArea">
</tbody>
</table>
</div>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="btn_wrap">
<div class="plm_btn_wrap_center">
<input type="button" value="저장" id="btnSave" class="plm_btns">
<input type="button" value="닫기" id="btnClose" class="plm_btns">
</div>
</div>
</section>
</form>
</body>
</html>