Files
wace_plm/WebContent/WEB-INF/view/quality/qualityBasicInfoList.jsp
2025-12-04 15:21:54 +09:00

669 lines
19 KiB
Plaintext

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.pms.common.utils.*"%>
<%@ page import="java.util.*" %>
<%@include file= "/init.jsp" %>
<%
// 검사구분 목록
ArrayList inspectionTypeList = (ArrayList)request.getAttribute("inspectionTypeList");
if(null == inspectionTypeList) inspectionTypeList = new ArrayList();
// 불량유형 목록
ArrayList defectTypeList = (ArrayList)request.getAttribute("defectTypeList");
if(null == defectTypeList) defectTypeList = new ArrayList();
// 불량원인 목록
ArrayList defectReasonList = (ArrayList)request.getAttribute("defectReasonList");
if(null == defectReasonList) defectReasonList = new ArrayList();
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><%=Constants.SYSTEM_NAME%></title>
<style>
/* 탭 스타일 */
.quality-tabs {
display: flex;
border-bottom: 2px solid #3c8dbc;
margin-bottom: 20px;
}
.quality-tabs .tab-btn {
padding: 12px 30px;
background: #f4f4f4;
border: 1px solid #ddd;
border-bottom: none;
cursor: pointer;
font-size: 14px;
font-weight: bold;
color: #333;
margin-right: 2px;
border-radius: 5px 5px 0 0;
transition: all 0.3s;
}
.quality-tabs .tab-btn:hover {
background: #e8e8e8;
}
.quality-tabs .tab-btn.active {
background: #3c8dbc;
color: #fff;
border-color: #3c8dbc;
}
.tab-content {
display: none;
padding: 20px;
border: 1px solid #ddd;
border-top: none;
background: #fff;
}
.tab-content.active {
display: block;
}
/* 테이블 스타일 */
.quality-table {
width: 100%;
border-collapse: collapse;
margin-top: 10px;
}
.quality-table th, .quality-table td {
border: 1px solid #ddd;
padding: 10px;
text-align: center;
}
.quality-table th {
background: #3c8dbc;
color: #fff;
font-weight: bold;
}
.quality-table tr:nth-child(even) {
background: #f9f9f9;
}
.quality-table tr:hover {
background: #e8f4fc;
}
/* 버튼 스타일 */
.quality-btn-wrap {
margin-bottom: 15px;
text-align: right;
}
.quality-btn {
padding: 8px 20px;
margin-left: 5px;
border: none;
border-radius: 3px;
cursor: pointer;
font-size: 13px;
}
.quality-btn.add {
background: #00a65a;
color: #fff;
}
.quality-btn.delete {
background: #dd4b39;
color: #fff;
}
.quality-btn.save {
background: #3c8dbc;
color: #fff;
}
/* 종속 선택 영역 */
.defect-reason-filter {
margin-bottom: 15px;
padding: 15px;
background: #f9f9f9;
border: 1px solid #ddd;
border-radius: 5px;
}
.defect-reason-filter label {
font-weight: bold;
margin-right: 10px;
}
.defect-reason-filter select {
padding: 8px 15px;
border: 1px solid #ccc;
border-radius: 3px;
min-width: 200px;
}
/* 입력 필드 */
.quality-table input[type="text"] {
width: 90%;
padding: 8px;
border: 1px solid #ccc;
border-radius: 3px;
}
.quality-table select {
width: 90%;
padding: 8px;
border: 1px solid #ccc;
border-radius: 3px;
}
</style>
</head>
<script type="text/javascript">
$(document).ready(function(){
// 탭 클릭 이벤트
$('.tab-btn').click(function(){
var tabId = $(this).data('tab');
// 탭 버튼 활성화
$('.tab-btn').removeClass('active');
$(this).addClass('active');
// 탭 콘텐츠 활성화
$('.tab-content').removeClass('active');
$('#' + tabId).addClass('active');
});
// 불량유형 선택 시 불량원인 필터링
$('#filterDefectType').change(function(){
fn_filterDefectReason($(this).val());
});
});
// =====================================================
// 검사구분 관리
// =====================================================
var inspectionTypeRowId = 0;
function fn_addInspectionType(){
inspectionTypeRowId++;
var html = '<tr id="inspectionTypeRow_' + inspectionTypeRowId + '" data-isnew="Y">';
html += '<td><input type="checkbox" name="inspectionTypeCheck" value="' + inspectionTypeRowId + '"></td>';
html += '<td><input type="text" name="INSPECTION_TYPE_NAME" placeholder="검사구분명 입력"></td>';
html += '<td><select name="STATUS"><option value="active">활성화</option><option value="inActive">비활성화</option></select></td>';
html += '<td>-</td>';
html += '</tr>';
$('#inspectionTypeTable tbody').append(html);
}
function fn_deleteInspectionType(){
var checked = $('input[name="inspectionTypeCheck"]:checked');
if(checked.length == 0){
Swal.fire("삭제할 항목을 선택해주세요.");
return;
}
Swal.fire({
title: '삭제 확인',
text: '선택한 항목을 삭제하시겠습니까?',
icon: 'warning',
showCancelButton: true,
confirmButtonText: '삭제',
cancelButtonText: '취소'
}).then((result) => {
if(result.isConfirmed){
checked.each(function(){
var row = $(this).closest('tr');
var objId = row.data('objid');
var isNew = row.data('isnew');
if(isNew == 'Y'){
row.remove();
} else {
// 서버에서 삭제
$.ajax({
url: '/quality/deleteQualityBasicInfo.do',
type: 'POST',
data: { OBJID: objId, TYPE: 'INSPECTION_TYPE' },
dataType: 'json',
success: function(data){
if(data.result){
row.remove();
} else {
Swal.fire(data.msg);
}
}
});
}
});
}
});
}
function fn_saveInspectionType(){
var dataList = [];
$('#inspectionTypeTable tbody tr').each(function(){
var row = $(this);
var data = {
OBJID: row.data('objid') || '',
IS_NEW: row.data('isnew') || 'N',
INSPECTION_TYPE_NAME: row.find('input[name="INSPECTION_TYPE_NAME"]').val() || row.find('td:eq(1)').text(),
STATUS: row.find('select[name="STATUS"]').val() || row.find('td:eq(2) select').val()
};
if(data.INSPECTION_TYPE_NAME){
dataList.push(data);
}
});
if(dataList.length == 0){
Swal.fire("저장할 데이터가 없습니다.");
return;
}
$.ajax({
url: '/quality/saveQualityBasicInfo.do',
type: 'POST',
data: { TYPE: 'INSPECTION_TYPE', DATA: JSON.stringify(dataList) },
dataType: 'json',
success: function(data){
Swal.fire(data.msg);
if(data.result){
location.reload();
}
}
});
}
// =====================================================
// 불량유형 관리
// =====================================================
var defectTypeRowId = 0;
function fn_addDefectType(){
defectTypeRowId++;
var html = '<tr id="defectTypeRow_' + defectTypeRowId + '" data-isnew="Y">';
html += '<td><input type="checkbox" name="defectTypeCheck" value="' + defectTypeRowId + '"></td>';
html += '<td><input type="text" name="DEFECT_TYPE_NAME" placeholder="불량유형명 입력"></td>';
html += '<td><select name="STATUS"><option value="active">활성화</option><option value="inActive">비활성화</option></select></td>';
html += '<td>-</td>';
html += '</tr>';
$('#defectTypeTable tbody').append(html);
}
function fn_deleteDefectType(){
var checked = $('input[name="defectTypeCheck"]:checked');
if(checked.length == 0){
Swal.fire("삭제할 항목을 선택해주세요.");
return;
}
Swal.fire({
title: '삭제 확인',
text: '선택한 항목을 삭제하시겠습니까? (종속된 불량원인도 함께 삭제됩니다)',
icon: 'warning',
showCancelButton: true,
confirmButtonText: '삭제',
cancelButtonText: '취소'
}).then((result) => {
if(result.isConfirmed){
checked.each(function(){
var row = $(this).closest('tr');
var objId = row.data('objid');
var isNew = row.data('isnew');
if(isNew == 'Y'){
row.remove();
} else {
$.ajax({
url: '/quality/deleteQualityBasicInfo.do',
type: 'POST',
data: { OBJID: objId, TYPE: 'DEFECT_TYPE' },
dataType: 'json',
success: function(data){
if(data.result){
row.remove();
} else {
Swal.fire(data.msg);
}
}
});
}
});
}
});
}
function fn_saveDefectType(){
var dataList = [];
$('#defectTypeTable tbody tr').each(function(){
var row = $(this);
var data = {
OBJID: row.data('objid') || '',
IS_NEW: row.data('isnew') || 'N',
DEFECT_TYPE_NAME: row.find('input[name="DEFECT_TYPE_NAME"]').val() || row.find('td:eq(1)').text(),
STATUS: row.find('select[name="STATUS"]').val() || row.find('td:eq(2) select').val()
};
if(data.DEFECT_TYPE_NAME){
dataList.push(data);
}
});
if(dataList.length == 0){
Swal.fire("저장할 데이터가 없습니다.");
return;
}
$.ajax({
url: '/quality/saveQualityBasicInfo.do',
type: 'POST',
data: { TYPE: 'DEFECT_TYPE', DATA: JSON.stringify(dataList) },
dataType: 'json',
success: function(data){
Swal.fire(data.msg);
if(data.result){
location.reload();
}
}
});
}
// =====================================================
// 불량원인 관리
// =====================================================
var defectReasonRowId = 0;
function fn_filterDefectReason(defectTypeObjId){
if(defectTypeObjId == ''){
$('#defectReasonTable tbody tr').show();
} else {
$('#defectReasonTable tbody tr').each(function(){
var row = $(this);
var rowDefectType = row.data('defect-type');
if(rowDefectType == defectTypeObjId || row.data('isnew') == 'Y'){
row.show();
} else {
row.hide();
}
});
}
}
function fn_addDefectReason(){
var selectedDefectType = $('#filterDefectType').val();
if(selectedDefectType == ''){
Swal.fire("불량유형을 먼저 선택해주세요.");
return;
}
defectReasonRowId++;
var defectTypeName = $('#filterDefectType option:selected').text();
var html = '<tr id="defectReasonRow_' + defectReasonRowId + '" data-isnew="Y" data-defect-type="' + selectedDefectType + '">';
html += '<td><input type="checkbox" name="defectReasonCheck" value="' + defectReasonRowId + '"></td>';
html += '<td>' + defectTypeName + '<input type="hidden" name="DEFECT_TYPE_OBJID" value="' + selectedDefectType + '"></td>';
html += '<td><input type="text" name="DEFECT_REASON_NAME" placeholder="불량원인명 입력"></td>';
html += '<td><select name="STATUS"><option value="active">활성화</option><option value="inActive">비활성화</option></select></td>';
html += '<td>-</td>';
html += '</tr>';
$('#defectReasonTable tbody').append(html);
}
function fn_deleteDefectReason(){
var checked = $('input[name="defectReasonCheck"]:checked');
if(checked.length == 0){
Swal.fire("삭제할 항목을 선택해주세요.");
return;
}
Swal.fire({
title: '삭제 확인',
text: '선택한 항목을 삭제하시겠습니까?',
icon: 'warning',
showCancelButton: true,
confirmButtonText: '삭제',
cancelButtonText: '취소'
}).then((result) => {
if(result.isConfirmed){
checked.each(function(){
var row = $(this).closest('tr');
var objId = row.data('objid');
var isNew = row.data('isnew');
if(isNew == 'Y'){
row.remove();
} else {
$.ajax({
url: '/quality/deleteQualityBasicInfo.do',
type: 'POST',
data: { OBJID: objId, TYPE: 'DEFECT_REASON' },
dataType: 'json',
success: function(data){
if(data.result){
row.remove();
} else {
Swal.fire(data.msg);
}
}
});
}
});
}
});
}
function fn_saveDefectReason(){
var dataList = [];
$('#defectReasonTable tbody tr:visible').each(function(){
var row = $(this);
var data = {
OBJID: row.data('objid') || '',
IS_NEW: row.data('isnew') || 'N',
DEFECT_TYPE_OBJID: row.find('input[name="DEFECT_TYPE_OBJID"]').val() || row.data('defect-type'),
DEFECT_REASON_NAME: row.find('input[name="DEFECT_REASON_NAME"]').val() || row.find('td:eq(2)').text(),
STATUS: row.find('select[name="STATUS"]').val() || row.find('td:eq(3) select').val()
};
if(data.DEFECT_REASON_NAME && data.DEFECT_TYPE_OBJID){
dataList.push(data);
}
});
if(dataList.length == 0){
Swal.fire("저장할 데이터가 없습니다.");
return;
}
$.ajax({
url: '/quality/saveQualityBasicInfo.do',
type: 'POST',
data: { TYPE: 'DEFECT_REASON', DATA: JSON.stringify(dataList) },
dataType: 'json',
success: function(data){
Swal.fire(data.msg);
if(data.result){
location.reload();
}
}
});
}
</script>
<body>
<form name="hiddenForm" id="hiddenForm" method="POST">
<input type="hidden" name="actionType" id="actionType">
<input type="hidden" name="objId" id="objId">
</form>
<section id="commonSection">
<div class="plmMainTitle">
<h2>기초정보관리</h2>
</div>
<!-- 탭 메뉴 -->
<div class="quality-tabs">
<button type="button" class="tab-btn active" data-tab="tab-inspection-type">검사구분</button>
<button type="button" class="tab-btn" data-tab="tab-defect-type">불량유형</button>
<button type="button" class="tab-btn" data-tab="tab-defect-reason">불량원인</button>
</div>
<!-- 탭1: 검사구분 -->
<div id="tab-inspection-type" class="tab-content active">
<div class="quality-btn-wrap">
<button type="button" class="quality-btn add" onclick="fn_addInspectionType()">추가</button>
<button type="button" class="quality-btn delete" onclick="fn_deleteInspectionType()">삭제</button>
<button type="button" class="quality-btn save" onclick="fn_saveInspectionType()">저장</button>
</div>
<table id="inspectionTypeTable" class="quality-table">
<thead>
<tr>
<th style="width:50px;">선택</th>
<th>검사구분명</th>
<th style="width:150px;">상태</th>
<th style="width:150px;">등록일</th>
</tr>
</thead>
<tbody>
<%
if(inspectionTypeList.size() > 0){
for(int i=0; i<inspectionTypeList.size(); i++){
HashMap map = (HashMap)inspectionTypeList.get(i);
String OBJID = CommonUtils.checkNull(map.get("OBJID"));
String INSPECTION_TYPE_NAME = CommonUtils.checkNull(map.get("INSPECTION_TYPE_NAME"));
String STATUS = CommonUtils.checkNull(map.get("STATUS"));
String REG_DATE = CommonUtils.checkNull(map.get("REG_DATE"));
%>
<tr data-objid="<%=OBJID%>" data-isnew="N">
<td><input type="checkbox" name="inspectionTypeCheck" value="<%=OBJID%>"></td>
<td><%=INSPECTION_TYPE_NAME%></td>
<td>
<select name="STATUS">
<option value="active" <%="active".equals(STATUS)?"selected":""%>>활성화</option>
<option value="inActive" <%="inActive".equals(STATUS)?"selected":""%>>비활성화</option>
</select>
</td>
<td><%=REG_DATE%></td>
</tr>
<%
}
} else {
%>
<tr class="empty-row">
<td colspan="4">등록된 검사구분이 없습니다.</td>
</tr>
<%
}
%>
</tbody>
</table>
</div>
<!-- 탭2: 불량유형 -->
<div id="tab-defect-type" class="tab-content">
<div class="quality-btn-wrap">
<button type="button" class="quality-btn add" onclick="fn_addDefectType()">추가</button>
<button type="button" class="quality-btn delete" onclick="fn_deleteDefectType()">삭제</button>
<button type="button" class="quality-btn save" onclick="fn_saveDefectType()">저장</button>
</div>
<table id="defectTypeTable" class="quality-table">
<thead>
<tr>
<th style="width:50px;">선택</th>
<th>불량유형명</th>
<th style="width:150px;">상태</th>
<th style="width:150px;">등록일</th>
</tr>
</thead>
<tbody>
<%
if(defectTypeList.size() > 0){
for(int i=0; i<defectTypeList.size(); i++){
HashMap map = (HashMap)defectTypeList.get(i);
String OBJID = CommonUtils.checkNull(map.get("OBJID"));
String DEFECT_TYPE_NAME = CommonUtils.checkNull(map.get("DEFECT_TYPE_NAME"));
String STATUS = CommonUtils.checkNull(map.get("STATUS"));
String REG_DATE = CommonUtils.checkNull(map.get("REG_DATE"));
%>
<tr data-objid="<%=OBJID%>" data-isnew="N">
<td><input type="checkbox" name="defectTypeCheck" value="<%=OBJID%>"></td>
<td><%=DEFECT_TYPE_NAME%></td>
<td>
<select name="STATUS">
<option value="active" <%="active".equals(STATUS)?"selected":""%>>활성화</option>
<option value="inActive" <%="inActive".equals(STATUS)?"selected":""%>>비활성화</option>
</select>
</td>
<td><%=REG_DATE%></td>
</tr>
<%
}
} else {
%>
<tr class="empty-row">
<td colspan="4">등록된 불량유형이 없습니다.</td>
</tr>
<%
}
%>
</tbody>
</table>
</div>
<!-- 탭3: 불량원인 -->
<div id="tab-defect-reason" class="tab-content">
<div class="defect-reason-filter">
<label>불량유형 선택:</label>
<select id="filterDefectType">
<option value="">전체</option>
<%
for(int i=0; i<defectTypeList.size(); i++){
HashMap map = (HashMap)defectTypeList.get(i);
String OBJID = CommonUtils.checkNull(map.get("OBJID"));
String DEFECT_TYPE_NAME = CommonUtils.checkNull(map.get("DEFECT_TYPE_NAME"));
%>
<option value="<%=OBJID%>"><%=DEFECT_TYPE_NAME%></option>
<%
}
%>
</select>
<span style="margin-left:20px; color:#666; font-size:12px;">※ 불량유형을 선택하면 해당 유형의 불량원인만 표시됩니다.</span>
</div>
<div class="quality-btn-wrap">
<button type="button" class="quality-btn add" onclick="fn_addDefectReason()">추가</button>
<button type="button" class="quality-btn delete" onclick="fn_deleteDefectReason()">삭제</button>
<button type="button" class="quality-btn save" onclick="fn_saveDefectReason()">저장</button>
</div>
<table id="defectReasonTable" class="quality-table">
<thead>
<tr>
<th style="width:50px;">선택</th>
<th style="width:200px;">불량유형</th>
<th>불량원인명</th>
<th style="width:150px;">상태</th>
<th style="width:150px;">등록일</th>
</tr>
</thead>
<tbody>
<%
if(defectReasonList.size() > 0){
for(int i=0; i<defectReasonList.size(); i++){
HashMap map = (HashMap)defectReasonList.get(i);
String OBJID = CommonUtils.checkNull(map.get("OBJID"));
String DEFECT_TYPE_OBJID = CommonUtils.checkNull(map.get("DEFECT_TYPE_OBJID"));
String DEFECT_TYPE_NAME = CommonUtils.checkNull(map.get("DEFECT_TYPE_NAME"));
String DEFECT_REASON_NAME = CommonUtils.checkNull(map.get("DEFECT_REASON_NAME"));
String STATUS = CommonUtils.checkNull(map.get("STATUS"));
String REG_DATE = CommonUtils.checkNull(map.get("REG_DATE"));
%>
<tr data-objid="<%=OBJID%>" data-isnew="N" data-defect-type="<%=DEFECT_TYPE_OBJID%>">
<td><input type="checkbox" name="defectReasonCheck" value="<%=OBJID%>"></td>
<td><%=DEFECT_TYPE_NAME%><input type="hidden" name="DEFECT_TYPE_OBJID" value="<%=DEFECT_TYPE_OBJID%>"></td>
<td><%=DEFECT_REASON_NAME%></td>
<td>
<select name="STATUS">
<option value="active" <%="active".equals(STATUS)?"selected":""%>>활성화</option>
<option value="inActive" <%="inActive".equals(STATUS)?"selected":""%>>비활성화</option>
</select>
</td>
<td><%=REG_DATE%></td>
</tr>
<%
}
} else {
%>
<tr class="empty-row">
<td colspan="5">등록된 불량원인이 없습니다.</td>
</tr>
<%
}
%>
</tbody>
</table>
</div>
</section>
</body>
</html>