403 lines
14 KiB
Plaintext
403 lines
14 KiB
Plaintext
<%@ 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.jsp" %>
|
|
<c:set var="now" value="<%=new java.util.Date() %>"/>
|
|
<c:set var="sysYear"><fmt:formatDate value="${now}" pattern="yyyy" /></c:set>
|
|
<%
|
|
String menuObjId = request.getParameter("menuObjId");
|
|
String menuName = CommonUtils.getMenuName(menuObjId, "공정검사 관리");
|
|
%>
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
<title><%=Constants.SYSTEM_NAME%></title>
|
|
</head>
|
|
|
|
<style>
|
|
body, html {
|
|
overflow-x: hidden;
|
|
width: 100%;
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
.select2-selection__choice {
|
|
font-size: 11px;
|
|
background-color: #fff !important;
|
|
border: none !important;
|
|
margin-right: 0px !important;
|
|
}
|
|
.select2-selection__choice__remove {
|
|
display: contents !important;
|
|
}
|
|
.select2-container .select2-selection--multiple {
|
|
min-height: 20px !important;
|
|
}
|
|
.select2-container--default .select2-selection--multiple .select2-selection__choice {
|
|
margin-top: 3.5px !important;
|
|
}
|
|
.select2-selection__rendered {
|
|
height: 18px !important;
|
|
}
|
|
.select2-container .select2-selection--multiple .select2-selection__rendered {
|
|
overflow: auto !important;
|
|
}
|
|
#search_part_no + .select2-container,
|
|
#search_part_name + .select2-container {
|
|
width: 210px !important;
|
|
}
|
|
/* 검사결과 스타일 */
|
|
.inspection-ng { color: #dc3545; font-weight: bold; }
|
|
.inspection-ok { color: #28a745; font-weight: bold; }
|
|
</style>
|
|
|
|
<script type="text/javascript">
|
|
$(document).ready(function(){
|
|
fnc_changePaginationAndTotalCountArea();
|
|
$('.select2').select2();
|
|
fnc_datepick();
|
|
|
|
$("input").keyup(function(e){
|
|
if(e.keyCode == 13){
|
|
$("#page").val("1");
|
|
fn_search();
|
|
}
|
|
});
|
|
// 품번/품명 Select2 AJAX 초기화
|
|
initPartSelect2Ajax("#search_part_no", "#search_part_name", "#search_part_objid", {
|
|
debug: false,
|
|
partNoPlaceholder: "품번 검색...",
|
|
partNamePlaceholder: "품명 검색..."
|
|
});
|
|
// 조회
|
|
$("#btnSearch").click(function(){
|
|
$("#page").val("1");
|
|
fn_search();
|
|
});
|
|
|
|
// 공정검사 등록
|
|
$("#btnRegist").click(function(){
|
|
fn_registPopUp();
|
|
});
|
|
|
|
// 엑셀 다운로드
|
|
$("#btnExcel").click(function(){
|
|
fn_excelDownload();
|
|
});
|
|
|
|
fn_search();
|
|
});
|
|
|
|
// 컬럼: 검사일, 프로젝트번호, 품번, 품명, 불량수량, 작업환경상태, 측정기, 검사자, 검사결과
|
|
var columns = [
|
|
{headerHozAlign:'center', hozAlign:'center', minWidth:110, widthGrow:1, title:'검사일', field:'INSPECTION_DATE' },
|
|
{headerHozAlign:'center', hozAlign:'center', minWidth:100, widthGrow:1, title:'검사자', field:'INSPECTOR_NAME'},
|
|
{headerHozAlign:'center', hozAlign:'center', minWidth:150, widthGrow:2, title:'프로젝트번호', field:'PROJECT_NO'},
|
|
{headerHozAlign:'center', hozAlign:'center', minWidth:110, widthGrow:1, title:'제품구분', field:'PRODUCT_NAME'},
|
|
{headerHozAlign:'center', hozAlign:'left', minWidth:180, widthGrow:2, title:'품번', field:'PART_NO'},
|
|
{headerHozAlign:'center', hozAlign:'left', minWidth:200, widthGrow:3, title:'품명', field:'PART_NAME'},
|
|
{headerHozAlign:'center', hozAlign:'right', minWidth:100, widthGrow:1, title:'검사수량 합계', field:'INSPECTION_QTY',
|
|
formatter:"money", formatterParams:{thousand:",", precision:false}
|
|
},
|
|
// {headerHozAlign:'center', hozAlign:'right', minWidth:100, widthGrow:1, title:'불량수량 합계', field:'DEFECT_QTY',
|
|
// formatter:"money", formatterParams:{thousand:",", precision:false}
|
|
// },
|
|
// {headerHozAlign:'center', hozAlign:'center', minWidth:120, widthGrow:1, title:'작업환경상태', field:'WORK_ENV_STATUS'},
|
|
// {headerHozAlign:'center', hozAlign:'center', minWidth:100, widthGrow:1, title:'측정기', field:'MEASURING_DEVICE'},
|
|
|
|
{headerHozAlign:'center', hozAlign:'center', minWidth:100, widthGrow:1, title:'검사결과', field:'INSPECTION_RESULT',
|
|
formatter: function(cell, formatterParams, onRendered){
|
|
var val = fnc_checkNull(cell.getValue());
|
|
if(val === 'NG') return '<span class="inspection-ng">NG</span>';
|
|
if(val === 'OK') return '<span class="inspection-ok">OK</span>';
|
|
return val;
|
|
},
|
|
cellClick: function(e, cell){
|
|
fn_openFormPopUp(cell.getData().OBJID);
|
|
}
|
|
},
|
|
{headerHozAlign:'center', hozAlign:'center', minWidth:100, widthGrow:1, title:'첨부파일', field:'PROCESS_INSPECTION_FILE_CNT',
|
|
formatter: fnc_subInfoValueFormatter,
|
|
cellClick: function(e, cell){
|
|
var objId = fnc_checkNull(cell.getData().OBJID);
|
|
fn_openAttachFilePopUp(objId);
|
|
}
|
|
}
|
|
];
|
|
|
|
// 수정 팝업
|
|
function fn_openFormPopUp(objId){
|
|
var popup_width = 1500;
|
|
var popup_height = 700;
|
|
var url = "/quality/processInspectionFormPopUp.do?OBJID=" + objId;
|
|
window.open(url, "processInspectionPopUp", "width=" + popup_width + ",height=" + popup_height + ",scrollbars=yes,resizable=yes");
|
|
}
|
|
|
|
// 조회
|
|
function fn_search(){
|
|
_tabulGrid = fnc_tabul_search(_tabul_layout_fitColumns, _tabulGrid, "/quality/processInspectionGridList.do", columns, true);
|
|
}
|
|
|
|
// 검색조건 초기화
|
|
function fn_reset(){
|
|
$("#search_inspection_date_from").val("");
|
|
$("#search_inspection_date_to").val("");
|
|
$("#search_inspector").val("");
|
|
$("#search_project_no").val("");
|
|
$("#search_part_no").val("");
|
|
$("#search_part_name").val("");
|
|
$("#search_inspection_result").val("");
|
|
}
|
|
|
|
// 공정검사 등록 팝업
|
|
function fn_registPopUp(){
|
|
var popup_width = 1500;
|
|
var popup_height = 700;
|
|
var url = "/quality/processInspectionFormPopUp.do";
|
|
|
|
window.open(url, "processInspectionPopUp", "width=" + popup_width + ",height=" + popup_height + ",scrollbars=yes,resizable=yes");
|
|
}
|
|
|
|
function fn_openAttachFilePopUp(objId) {
|
|
_filePopupOpen = true; // 파일 팝업 열림 플래그 설정
|
|
|
|
var popup_width = 800;
|
|
var popup_height = 300;
|
|
var params = "?targetObjId=" + objId + "&docType=PROCESS_INSPECTION_FILE&docTypeName=공정검사첨부";
|
|
var url = "/common/FileRegistPopup.do" + params;
|
|
var popup = window.open(url, "attachFilePopUp", "width=" + popup_width + ",height=" + popup_height + ",scrollbars=yes,resizable=yes");
|
|
|
|
// 팝업 닫힘 감지하여 해당 행의 파일 카운트만 업데이트
|
|
fn_watchPopupClose(popup, objId, 'ATTACH_FILE_CNT', 'PROCESS_INSPECTION_FILE');
|
|
}
|
|
|
|
// 엑셀 다운로드 (전체 데이터 풀어서 - ExcelJS)
|
|
function fn_excelDownload(){
|
|
var params = {
|
|
search_project_no: $("#search_project_no").val() || "",
|
|
productType: $("#productType").val() || "",
|
|
search_part_no: $("#search_part_no").val() || "",
|
|
search_part_name: $("#search_part_name").val() || "",
|
|
search_inspection_date_from: $("#search_inspection_date_from").val() || "",
|
|
search_inspection_date_to: $("#search_inspection_date_to").val() || "",
|
|
search_inspector: $("#search_inspector").val() || "",
|
|
search_inspection_result: $("#search_inspection_result").val() || ""
|
|
};
|
|
|
|
$.ajax({
|
|
url: "/quality/getProcessInspectionListForExcel.do",
|
|
type: "POST",
|
|
data: params,
|
|
dataType: "json",
|
|
success: function(result){
|
|
console.log("엑셀 데이터:", result);
|
|
if(result && result.list && result.list.length > 0){
|
|
fn_createExcelFile(result.list);
|
|
} else {
|
|
Swal.fire("다운로드할 데이터가 없습니다.");
|
|
}
|
|
},
|
|
error: function(xhr, status, error){
|
|
console.error("엑셀 데이터 조회 실패:", error);
|
|
console.error("상태:", status);
|
|
console.error("응답:", xhr.responseText);
|
|
Swal.fire("엑셀 데이터 조회 중 오류가 발생했습니다.");
|
|
}
|
|
});
|
|
}
|
|
|
|
// ExcelJS로 엑셀 파일 생성 (전체 풀어서)
|
|
async function fn_createExcelFile(data){
|
|
try {
|
|
var pageTitle = "공정검사관리";
|
|
const workbook = new ExcelJS.Workbook();
|
|
const worksheet = workbook.addWorksheet(pageTitle);
|
|
|
|
// 헤더 설정 (모든 컬럼 포함: 제품구분, 공정명, 부서, 작업자, 디테일비고, 조치현황)
|
|
var headers = ["No", "검사일", "검사자", "제품구분", "공정명", "프로젝트번호", "품번", "품명",
|
|
"검사수량", "불량수량", "불량율(%)", "작업환경상태", "측정기", "부서", "작업자", "디테일비고", "조치현황", "검사결과"];
|
|
|
|
// 열 너비 설정
|
|
var colWidths = [6, 12, 12, 15, 12, 18, 18, 22, 12, 12, 10, 14, 10, 12, 12, 15, 12, 10];
|
|
colWidths.forEach(function(width, idx){
|
|
worksheet.getColumn(idx + 1).width = width;
|
|
});
|
|
|
|
// 헤더 행 추가
|
|
var headerRow = worksheet.addRow(headers);
|
|
|
|
// 헤더 스타일 (노란색 배경)
|
|
headerRow.eachCell(function(cell){
|
|
cell.fill = {
|
|
type: 'pattern',
|
|
pattern: 'solid',
|
|
fgColor: { argb: 'FFFFFF00' } // 노란색
|
|
};
|
|
cell.font = { bold: true };
|
|
cell.alignment = { vertical: 'middle', horizontal: 'center' };
|
|
cell.border = {
|
|
top: { style: 'thin' },
|
|
left: { style: 'thin' },
|
|
bottom: { style: 'thin' },
|
|
right: { style: 'thin' }
|
|
};
|
|
});
|
|
|
|
// 데이터 추가 (모든 컬럼 포함)
|
|
data.forEach(function(item, index){
|
|
var row = worksheet.addRow([
|
|
index + 1,
|
|
item.inspection_date || item.INSPECTION_DATE || "",
|
|
item.inspector_name || item.INSPECTOR_NAME || "",
|
|
item.product_type || item.PRODUCT_TYPE || "",
|
|
item.process_name || item.PROCESS_NAME || "",
|
|
item.project_no || item.PROJECT_NO || "",
|
|
item.part_no || item.PART_NO || "",
|
|
item.part_name || item.PART_NAME || "",
|
|
item.inspection_qty || item.INSPECTION_QTY || 0,
|
|
item.defect_qty || item.DEFECT_QTY || 0,
|
|
item.defect_rate || item.DEFECT_RATE || 0,
|
|
item.work_env_status || item.WORK_ENV_STATUS || "",
|
|
item.measuring_device || item.MEASURING_DEVICE || "",
|
|
item.dept_name || item.DEPT_NAME || "",
|
|
item.user_name || item.USER_NAME || "",
|
|
item.detail_remark || item.DETAIL_REMARK || "",
|
|
item.action_status || item.ACTION_STATUS || "",
|
|
item.inspection_result || item.INSPECTION_RESULT || ""
|
|
]);
|
|
|
|
// 데이터 행 스타일
|
|
row.eachCell(function(cell){
|
|
cell.border = {
|
|
top: { style: 'thin' },
|
|
left: { style: 'thin' },
|
|
bottom: { style: 'thin' },
|
|
right: { style: 'thin' }
|
|
};
|
|
});
|
|
});
|
|
|
|
// 파일명 생성
|
|
var today = new Date();
|
|
var dateStr = today.getFullYear() + ("0" + (today.getMonth()+1)).slice(-2) + ("0" + today.getDate()).slice(-2);
|
|
var fileName = pageTitle + "_" + dateStr + ".xlsx";
|
|
|
|
// 다운로드
|
|
const buffer = await workbook.xlsx.writeBuffer();
|
|
saveAs(new Blob([buffer]), fileName);
|
|
} catch(e) {
|
|
console.error("엑셀 생성 오류:", e);
|
|
Swal.fire("엑셀 파일 생성 중 오류가 발생했습니다.");
|
|
}
|
|
}
|
|
|
|
</script>
|
|
|
|
<body>
|
|
<form name="hiddenForm" id="hiddenForm" method="post">
|
|
<input type="hidden" name="OBJID" id="OBJID">
|
|
<input type="hidden" name="actionType" id="actionType">
|
|
</form>
|
|
|
|
<form name="form1" id="form1" action="" method="post">
|
|
<div class="content-box" style="height: 99.3%;">
|
|
<div class="content-box-s">
|
|
<div class="plm_menu_name_gdnsi">
|
|
<h2>
|
|
<span><%=menuName%></span>
|
|
</h2>
|
|
<div class="btnArea">
|
|
<input type="button" class="plm_btns" value="공정검사 등록" id="btnRegist">
|
|
<input type="button" class="plm_btns" value="조회" id="btnSearch">
|
|
<input type="button" class="plm_btns" value="Excel Download" id="btnExcel">
|
|
</div>
|
|
</div>
|
|
|
|
<div id="plmSearchZon">
|
|
<table>
|
|
<tr>
|
|
<td><label for="">프로젝트번호</label></td>
|
|
<td>
|
|
<select name="search_project_no" id="search_project_no" style="width:215px;" class="select2" autocomplete="off">
|
|
<option value="">전체</option>
|
|
${code_map.project_no}
|
|
</select>
|
|
</td>
|
|
|
|
<td><label for="">제품구분</label></td>
|
|
<td>
|
|
<select name="productType" id="productType" style="width:150px;" class="select2" autocomplete="off">
|
|
<option value="">전체</option>
|
|
${code_map.product_cd}
|
|
</select>
|
|
</td>
|
|
|
|
<td><label>품번</label></td>
|
|
<td>
|
|
<select name="search_part_no" id="search_part_no" class="select2-part" style="">
|
|
<option value="">품번 선택</option>
|
|
</select>
|
|
<input type="hidden" name="search_part_objid" id="search_part_objid" value="">
|
|
</td>
|
|
<td><label>품명</label></td>
|
|
<td>
|
|
<select name="search_part_name" id="search_part_name" class="select2-part" style="">
|
|
<option value="">품명 선택</option>
|
|
</select>
|
|
</td>
|
|
|
|
<td><label for="">작업환경상태</label></td>
|
|
<td>
|
|
<select name="search_work_env_status" id="search_work_env_status" style="">
|
|
<option value="">전체</option>
|
|
<option value="OK">양호</option>
|
|
<option value="NG">불량</option>
|
|
</select>
|
|
</td>
|
|
|
|
<td><label for="">측정기</label></td>
|
|
<td>
|
|
<select name="search_measuring_device" id="search_measuring_device" style="">
|
|
<option value="">전체</option>
|
|
<option value="OK">양호</option>
|
|
<option value="NG">불량</option>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class=""><label>검사일</label></td>
|
|
<td>
|
|
<input type="text" name="search_inspection_date_from" id="search_inspection_date_from" style="width:100px;" autocomplete="off" value="${param.search_inspection_date_from}" class="date_icon">~
|
|
<input type="text" name="search_inspection_date_to" id="search_inspection_date_to" style="width:100px;" autocomplete="off" value="${param.search_inspection_date_to}" class="date_icon">
|
|
</td>
|
|
|
|
<td><label for="">검사자</label></td>
|
|
<td>
|
|
<select name="search_inspector" id="search_inspector" style="width:150px;" class="select2" autocomplete="off">
|
|
<option value="">전체</option>
|
|
${code_map.inspector_id}
|
|
</select>
|
|
</td>
|
|
|
|
<td><label for="">검사결과</label></td>
|
|
<td>
|
|
<select name="search_inspection_result" id="search_inspection_result" style="width:210px;">
|
|
<option value="">전체</option>
|
|
<option value="OK">OK</option>
|
|
<option value="NG">NG</option>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<%@include file= "/WEB-INF/view/common/common_gridArea.jsp" %>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</body>
|
|
</html>
|