fix: 신청서접수 제품목록 변경 기능 추가로 화면 분리 처리
parent
3bdd4dec18
commit
012d501a9f
@ -0,0 +1,685 @@
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false" session="false"%>
|
||||
<%@ include file="/WEB-INF/jsp/include/taglib.jsp"%>
|
||||
|
||||
<c:set var="prefixName" scope="request">폐기관리 등록</c:set>
|
||||
|
||||
<!-- inner page html -->
|
||||
<div class="content-wrapper">
|
||||
<!-- Content -->
|
||||
<div class="container flex-grow-1 px-0">
|
||||
<!-- Page Body -->
|
||||
<div class="card">
|
||||
<!-- 입력 영역 -->
|
||||
<form id="bssh--${pageName}" name="bssh">
|
||||
<!-- hidden -->
|
||||
<input type="hidden" name="dscdmngId" data-map="dscdmngId" />
|
||||
<input type="hidden" name="prgrsSttsCd" data-map="prgrsSttsCd" />
|
||||
<label for="bssh--${pageName}" style="margin-top: 10px; padding-left: 20px;"><strong>취급 업체 정보</strong></label>
|
||||
<div class="row my-1 mx-4 g-1 border-card rounded-3">
|
||||
<div class="col-md-4">
|
||||
<label for="bsshNm--${pageName}" class="w-px-100 bg-lighter pe-2 col-form-label text-sm-end">업체명</label>
|
||||
<input type="text" class="form-control w-70" id="bsshNm--${pageName}" name="bsshNm" data-map="bsshNm" readonly>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<label for="bsshCd--${pageName}" class="w-px-100 bg-lighter pe-2 col-form-label text-sm-end">식별번호</label>
|
||||
<input type="text" class="form-control w-px-150" id="bsshNm--${pageName}" name="bsshCd" data-map="bsshCd" readonly>
|
||||
<button type="button" class="btn btn-search w-px-100" id="btnBsshSearch--${pageName}" title="업체 검색">업체 검색</button>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="rprsntvNm--${pageName}" class="w-px-100 bg-lighter pe-2 col-form-label text-sm-end">대표자명</label>
|
||||
<input type="text" class="form-control w-70" id="rprsntvNm--${pageName}" name="rprsntvNm" data-map="rprsntvNm" readonly>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="prmisnNo--${pageName}" class="w-px-100 bg-lighter pe-2 col-form-label text-sm-end">허가번호</label>
|
||||
<input type="text" class="form-control w-70" id="prmisnNo--${pageName}" name="prmisnNo" data-map="prmisnNo" readonly>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="bizrNo--${pageName}" class="w-px-110 bg-lighter pe-2 col-form-label text-sm-end">사업자등록번호</label>
|
||||
<input type="text" class="form-control w-60" id="bizrno--${pageName}" name="bizrno" data-map="bizrno" readonly>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="dsusePrvCd--${pageName}" class="w-px-100 bg-lighter pe-2 col-form-label text-sm-end">폐기사유</label>
|
||||
<select class="form-select" id="dsusePrvCd--${pageName}" name="dsusePrvCd">
|
||||
<c:forEach items="${ADDS04}" var="item">
|
||||
<option value="${item.code}">${item.value}</option>
|
||||
</c:forEach>
|
||||
</select>
|
||||
</div>
|
||||
<div id="divDsuseAcdtDe" class="col-md-4">
|
||||
<label for="dsusePrvCd--${pageName}" class="w-px-100 bg-lighter pe-2 col-form-label text-sm-end">사고발생일</label>
|
||||
<input type="text" class="form-control form-date" id="dsuseAcdtDe--${pageName}" name="dsuseAcdtDe" data-fmt-type="day" autocomplete="off" title="사고 발생일" />
|
||||
<button type="button" class="bx bx-lg bx-calendar bg-white"></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row my-1 mx-1 g-1 border-card rounded"></div>
|
||||
</form>
|
||||
<form id="product--${pageName}" name="product">
|
||||
<label for="product--${pageName}" style="margin-top: 10px; padding-left: 20px;"><strong>폐기 제품 정보</strong></label>
|
||||
<div class="row my-1 mx-4 g-1 border-card rounded-3">
|
||||
<div class="col-md-6">
|
||||
<label for="prductNm--${pageName}" class="w-px-100 bg-lighter pe-2 col-form-label text-sm-end">제품명</label>
|
||||
<input type="text" class="form-control w-75" id="prductNm--${pageName}" name="prductNm" data-map="prductNm" readonly>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="prductCd--${pageName}" class="w-px-100 bg-lighter pe-2 col-form-label text-sm-end">제품코드</label>
|
||||
<input type="text" class="form-control w-px-140" id="prductCd--${pageName}" name="prductCd" data-map="prductCd" readonly>
|
||||
<button type="button" class="btn btn-search w-px-100" id="btnProductSearch--${pageName}" title="제품 검색">제품 검색</button>
|
||||
<button type="button" class="btn btn-search w-px-100" id="btnProductBarcodeSearch--${pageName}" title="바코드 입력">바코드 입력</button>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="prdValidDe--${pageName}" class="w-px-100 bg-lighter pe-2 col-form-label text-sm-end">유효기간</label>
|
||||
<input type="text" class="form-control w-40" id="prdValidDe--${pageName}" name="prdValidDe" data-map="prdValidDe">
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="mnfNo--${pageName}" class="w-px-100 bg-lighter pe-2 col-form-label text-sm-end">제조번호</label>
|
||||
<input type="text" class="form-control w-60" id="mnfNo--${pageName}" name="mnfNo" data-map="mnfNo">
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="mnfSeq--${pageName}" class="w-px-100 bg-lighter pe-2 col-form-label text-sm-end">제조일련번호</label>
|
||||
<input type="text" class="form-control w-60" id="mnfSeq--${pageName}" name="mnfSeq" data-map="mnfSeq">
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="prdMinDistbQy--${pageName}" class="w-px-100 bg-lighter pe-2 col-form-label text-sm-end">유통단위 수량</label>
|
||||
<input type="text" class="form-control w-20" id="prdMinDistbQy--${pageName}" name="minDistbQy" data-map="prdMinDistbQy">
|
||||
<input type="text" class="form-control w-20" id="stdPackngStleNm--${pageName}" name="minDistbUnit" data-map="stdPackngStleNm" readonly>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="prdTotPceQy--${pageName}" class="w-px-100 bg-lighter pe-2 col-form-label text-sm-end">낱개단위 수량</label>
|
||||
<input type="text" class="form-control w-20" id="prdTotPceQy--${pageName}" name="pceQy" data-map="prdTotPceQy">
|
||||
<input type="text" class="form-control w-20" id="pceCoUnitNm--${pageName}" name="pceUnit" data-map="pceCoUnitNm" readonly>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="dsuseQy--${pageName}" class="w-px-100 bg-lighter pe-2 col-form-label text-sm-end">폐기 수량</label>
|
||||
<input type="text" class="form-control w-20" id="dsuseQy--${pageName}" name="dsuseQy" data-map="dsuseQy">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row my-1 mx-1 g-1 border-card rounded"></div>
|
||||
<div>
|
||||
<span class="container-page-btn">
|
||||
<span class="container-window-btn-right">
|
||||
<!-- 업무 버튼 -->
|
||||
<button type="button" class="btn btn-primary w-px-80" id="btnAdd--${pageName}" title="제품 추가">제품 추가</button>
|
||||
<button type="button" class="btn btn-primary w-px-80" id="btnDel--${pageName}" title="제품 삭제">제품 삭제</button>
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
<form id="productList--${pageName}" name="productList">
|
||||
<div class="table-responsive ox-scroll oy-scroll h-px-300" id="table-responsive--${pageName}">
|
||||
<table class="table-layout-fixed dataTable datatables-ajax table table-bordered no-footer" id="DataTables_Table_0--productList" aria-describedby="DataTables_Table_0_info">
|
||||
<thead class="sticky-thead">
|
||||
<tr id="theadTr--productList"
|
||||
data-by="by--productList" data-by-output="byOutput--productList" data-main-option="mainOption--productList" data-sub-option="subOption--productList">
|
||||
<th class="sorting" style="width: 145.156px;">제품코드</th>
|
||||
<th class="sorting sorting_asc" aria-sort="ascending" style="width: 325.719px;">제품명</th>
|
||||
<th class="sorting" style="width: 90.469px;">폐기수량</th>
|
||||
<th class="sorting" style="width: 158.469px;">폐기 제품 사진</th>
|
||||
<th class="sorting" style="width: 120.469px;">유효기간</th>
|
||||
<th class="sorting" style="width: 160.141px;">제조번호</th>
|
||||
<th class="sorting" style="width: 160.141px;">일련번호</th>
|
||||
<th class="sorting" style="width: 130.469px;">유통단위수량</th>
|
||||
<th class="sorting" style="width: 130.469px;">낱개단위수량</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tbody--productList">
|
||||
</tbody>
|
||||
<template id="productListRow--productList">
|
||||
<tr data-key="{keyCnt}">
|
||||
<td class="cmn text-center" onclick="{onclick}" ondblclick="{ondblclick}">{prductCd}</td>
|
||||
<td onclick="{onclick}" ondblclick="{ondblclick}">{prductNm}</td>
|
||||
<%-- <td class="cmn text-end" onclick="{onclick}" ondblclick="{ondblclick}">{dsuseQy}</td>--%>
|
||||
<td class="cmn text-end" onclick="{onclick}" ondblclick="{ondblclick}"><input type="text" value="{dsuseQy}" name="dsuseQy" size="4"/></td>
|
||||
<td class="cmn text-center prdDsuseImg" onclick="{onclick}" ondblclick="{ondblclick}"></td>
|
||||
<%-- <td class="cmn text-center" onclick="{onclick}" ondblclick="{ondblclick}">{prdValidDe}</td>--%>
|
||||
<%-- <td class="cmn text-center" onclick="{onclick}" ondblclick="{ondblclick}">{mnfNo}</td>--%>
|
||||
<%-- <td class="cmn text-center" onclick="{onclick}" ondblclick="{ondblclick}">{mnfSeq}</td>--%>
|
||||
<td class="cmn text-center" onclick="{onclick}" ondblclick="{ondblclick}"><input type="text" value="{prdValidDe}" name="prdValidDe" size="8"/></td>
|
||||
<td class="cmn text-center" onclick="{onclick}" ondblclick="{ondblclick}"><input type="text" value="{mnfNo}" name="mnfNo" size="13"/></td>
|
||||
<td class="cmn text-center" onclick="{onclick}" ondblclick="{ondblclick}"><input type="text" value="{mnfSeq}" name="mnfSeq" size="13"/></td>
|
||||
<td class="cmn text-center" onclick="{onclick}" ondblclick="{ondblclick}">{minDistbQy} {minDistbUnit}</td>
|
||||
<td class="cmn text-center" onclick="{onclick}" ondblclick="{ondblclick}">{pceQy} {pceUnit}</td>
|
||||
</tr>
|
||||
</template>
|
||||
<template id="productListNotFound--productList">
|
||||
<tr class="odd">
|
||||
<td valign="top" colspan="13" class="dataTables_empty text-center">제품 정보를 찾지 못했습니다.</td>
|
||||
</tr>
|
||||
</template>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
</div> <!-- <div class="card"> -->
|
||||
<!-- 업무 버튼 표시 -->
|
||||
<div>
|
||||
<span class="container-page-btn">
|
||||
<span class="container-window-btn-right">
|
||||
<!-- 업무 버튼 -->
|
||||
<button type="button" class="btn btn-primary w-px-80" id="btnSave--${pageName}" title="저장">저장</button>
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
<!-- / 업무 버튼 표시 -->
|
||||
</div> <!-- / Content <div class="container flex-grow-1 px-0"> -->
|
||||
</div> <!-- / inner page html <div class="content-wrapper"> -->
|
||||
|
||||
<script>
|
||||
/**************************************************************************
|
||||
* Global Variable
|
||||
**************************************************************************/
|
||||
pageObject["${pageName}"] = {};
|
||||
prdRowKey = 0;
|
||||
|
||||
/**************************************************************************
|
||||
* script 진입
|
||||
**************************************************************************/
|
||||
$(document).ready(function() {
|
||||
// pageObject
|
||||
let $P = pageObject["${pageName}"];
|
||||
|
||||
|
||||
const fnPrdChange = (e) => {
|
||||
let key = e.target.closest('tr').dataset.key;
|
||||
let value = e.target.value;
|
||||
let name = e.target.name;
|
||||
//alert(JSON.stringify($P.productList.getData(key)));
|
||||
$P.productList.setValue(key, name, value);
|
||||
//alert(JSON.stringify($P.productList.getData(key)));
|
||||
}
|
||||
|
||||
const fnBarcodeSearch = (barcode) => {
|
||||
ajax.get({
|
||||
url : wctx.url("/adds/nims/getNimsPrdMnfSeqInfoOfBarcode.do")
|
||||
, data : {
|
||||
barcodeStr : barcode,
|
||||
userId : "${currentUser.account}"
|
||||
}
|
||||
, success : obj => {
|
||||
if (!obj.success){
|
||||
dialog.alert(obj.message);
|
||||
$("#prductCd--${pageName}").val("");
|
||||
$("#prductCd--${pageName}").prop("readonly", true);
|
||||
return false;
|
||||
}
|
||||
|
||||
let prdInfo = obj.data;
|
||||
$P.productFormFields.set(
|
||||
$P.productControl,
|
||||
{
|
||||
prductCd: prdInfo.prductCd,
|
||||
prductNm: prdInfo.prductNm,
|
||||
prdMinDistbQy: prdInfo.prdMinDistbQy,
|
||||
stdPackngStleNm: prdInfo.stdPackngStleNm,
|
||||
prdTotPceQy: prdInfo.prdTotPceQy,
|
||||
pceCoUnitNm: prdInfo.pceCoUnitNm,
|
||||
dsuseQy: prdInfo.dsuseQy,
|
||||
prdValidDe: prdInfo.mnfSeqInfos[0].prdValidDe,
|
||||
mnfNo: prdInfo.mnfSeqInfos[0].mnfNo,
|
||||
mnfSeq: prdInfo.mnfSeqInfos[0].mnfSeq,
|
||||
|
||||
}
|
||||
);
|
||||
$("#prductCd--${pageName}").prop("readonly", true);
|
||||
$("#dsuseQy--${pageName}").focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// FormFields
|
||||
$P.bsshFormFields = new AddsFormFields("#bssh--${pageName}");
|
||||
$P.productFormFields = new AddsFormFields("#product--${pageName}");
|
||||
|
||||
/**************************************************************************
|
||||
* DatasetControl
|
||||
**************************************************************************/
|
||||
$P.control = new DatasetControl({
|
||||
prefix: "dsuseMgtReceiptBssh"
|
||||
, prefixName: "마약류 취급업체 조회"
|
||||
, keymapper: info => info ? info.bsshCd : ""
|
||||
, dataGetter: obj => obj.${infoPrefix}Info
|
||||
, infoSize: "xl"
|
||||
});
|
||||
|
||||
$P.bsshList = new Dataset({
|
||||
prefix: "dsuseMgtReceiptBsshList"
|
||||
, prefixName: "마약류 취급업체 조회"
|
||||
, keymapper: info => info ? info.bsshCd : ""
|
||||
, dataGetter: obj => obj
|
||||
, infoSize: "xl"
|
||||
});
|
||||
|
||||
$P.productControl = new DatasetControl({
|
||||
prefix: "dsuseMgtReceiptProduct"
|
||||
, prefixName: "마약류 제품 조회"
|
||||
, keymapper: info => info ? info.keyCnt : ""
|
||||
, dataGetter: obj => obj.${infoPrefix}Info
|
||||
, infoSize: "xl"
|
||||
});
|
||||
|
||||
$P.productList = new Dataset({
|
||||
prefix: "dsuseMgtReceiptProductList"
|
||||
, prefixName: "마약류 제품 조회"
|
||||
, keymapper: info => info ? info.keyCnt : ""
|
||||
, dataGetter: obj => {
|
||||
if (!obj.success){
|
||||
dialog.alert(obj.message);
|
||||
return false;
|
||||
}
|
||||
return obj.data;
|
||||
}
|
||||
, infoSize: "xl"
|
||||
, formats: {
|
||||
prdValidDe: dateFormat
|
||||
}
|
||||
});
|
||||
|
||||
/**************************************************************************
|
||||
* DatasetControl 이벤트
|
||||
**************************************************************************/
|
||||
// 현재 선택 자료 변경 이벤트
|
||||
$P.control.onCurrentChange = item => {
|
||||
if (!item){
|
||||
$("#dsusePrvCd--${pageName}").val("03");
|
||||
$("#dsuseAcdtDe--${pageName}").prop('disabled', true);
|
||||
$("#dsuseAcdtDe--${pageName}").val("");
|
||||
return;
|
||||
}
|
||||
|
||||
$P.bsshFormFields.set($P.control, item);
|
||||
|
||||
// 보고완료 데이타 변경 불가
|
||||
if($("input[name='prgrsSttsCd']").val() == '99') {
|
||||
$("#btnSave--${pageName}").prop("disabled", true);
|
||||
}
|
||||
|
||||
let checkData = item.data.dsusePrvCd;
|
||||
if (checkData =="01" || checkData =="02") {
|
||||
$("#dsuseAcdtDe--${pageName}").prop('disabled', false);
|
||||
}else{
|
||||
$("#dsuseAcdtDe--${pageName}").prop('disabled', true);
|
||||
$("#dsuseAcdtDe--${pageName}").val("");
|
||||
}
|
||||
}
|
||||
|
||||
$P.productControl.onCurrentChange = item => {
|
||||
if (!item) return;
|
||||
|
||||
// Dataset 셋팅
|
||||
$P.productFormFields.set($P.productControl, item);
|
||||
}
|
||||
|
||||
// 저장 callback
|
||||
$P.control.onSave = (resp) => {
|
||||
let dialogTitle = $("#" + $P.control.prefix + "Dialog--${openerPageName}").find("h5.modal-title").html();
|
||||
let showMessage = resp.rtnMsg.replace(/[S]|[F]/g, dialogTitle);
|
||||
|
||||
// 메시지 출력
|
||||
dialog.alert({
|
||||
content: showMessage
|
||||
, init: () => { setDialogZindex(); }
|
||||
, onOK: () => { }
|
||||
});
|
||||
|
||||
if (resp.saved) {
|
||||
dialog.close($P.control.prefix + "Dialog--${openerPageName}");
|
||||
}
|
||||
}
|
||||
|
||||
$P.control.getBsshInfo = () => {
|
||||
let dialogTitle = "마약류 취급업체 조회";
|
||||
let params = {openPage : "bssh--${pageName}"};
|
||||
|
||||
ajax.get({
|
||||
url : wctx.url("/adds/nims/bssh-popup.do")
|
||||
, data : params
|
||||
, success : resp => {
|
||||
dialog.open({
|
||||
id : "bsshPopupDialog"
|
||||
, title : dialogTitle
|
||||
, content : resp
|
||||
, size : $P.control.infoSize
|
||||
, onClose : () => { $P.control.setData(); }
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$P.productControl.getProductInfo = () => {
|
||||
let dialogTitle = "마약류 제품 조회";
|
||||
let params = {openPage : "product--${pageName}"};
|
||||
|
||||
ajax.get({
|
||||
url : wctx.url("/adds/nims/product-popup.do")
|
||||
, data : params
|
||||
, success : resp => {
|
||||
dialog.open({
|
||||
id : "productMainDialog"
|
||||
, title : dialogTitle
|
||||
, content : resp
|
||||
, size : $P.productControl.infoSize
|
||||
, onClose : () => { $P.productControl.setData(); }
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 저장
|
||||
$P.control.save = (jsonBssh, datasetListPrd, fileArr) => {
|
||||
let saveBsshData = {
|
||||
...jsonBssh,
|
||||
rndDtlRptCnt: datasetListPrd.length,
|
||||
userId: "${currentUser.account}"
|
||||
}
|
||||
|
||||
upload({
|
||||
url: wctx.url("/adds/nims/saveDsuseMgtReceipt.do")
|
||||
, data: {
|
||||
dsuseMgtJsonStr: JSON.stringify(saveBsshData),
|
||||
dsuseMgtDtlsJsonStr: JSON.stringify(datasetListPrd),
|
||||
// 폐기상품이미지목록
|
||||
dsusePrdImgFiles: fileArr
|
||||
}
|
||||
, success: resp => {
|
||||
if(!resp.success){
|
||||
dialog.alert({
|
||||
content: resp.message
|
||||
});
|
||||
return;
|
||||
}
|
||||
dialog.alert("처리 되었습니다.");
|
||||
dialog.close("dsuseMgtReceiptDialog");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$P.productList.onAppend = item => {
|
||||
|
||||
if (!item) return;
|
||||
if (item.length < 1) return;
|
||||
|
||||
// 업무별 DataTables(그리드) tr, td
|
||||
let foundContent = document.getElementById("productListRow--productList").content;
|
||||
let foundTr = $(foundContent).find("tr")[0].cloneNode(false);
|
||||
let foundTds = $(foundContent).find("td");
|
||||
|
||||
foundTds.each(function() {
|
||||
foundTr.appendChild(this.cloneNode(true));
|
||||
});
|
||||
|
||||
//
|
||||
let replacer = (str, dataItem) => str
|
||||
.replace(/{onclick}/gi, "pageObject['${pageName}'].productList.setCurrent('" + dataItem.getValue("keyCnt") + "');");
|
||||
|
||||
|
||||
for(let i=0; i<item.length; i++){
|
||||
let di = $P.productList.getData(item[i].keyCnt, "item");
|
||||
|
||||
let tr = di.inString(foundTr.outerHTML, replacer);
|
||||
|
||||
$("#tbody--productList").append(tr);
|
||||
|
||||
fnMakeGridImageViewer(
|
||||
$("#tbody--productList").find("td.prdDsuseImg").last()[0],
|
||||
"dsusePrdImgFiles",
|
||||
di.data.fileInfo
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$P.productList.onRemove = item => {
|
||||
|
||||
let key = item[0].data.keyCnt;
|
||||
|
||||
$("#tbody--productList").find("tr[data-key='"+key+"']").remove();
|
||||
}
|
||||
|
||||
$P.productList.onCurrentChange = item => {
|
||||
if (!item) return;
|
||||
|
||||
let key = item.data.keyCnt;
|
||||
$("#tbody--productList").setCurrentRow(key);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* DataTables 이벤트
|
||||
**************************************************************************/
|
||||
|
||||
/**************************************************************************
|
||||
* 사용자 함수(function)
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
$P.fnSearchBssh = (title) => {
|
||||
$P.control.getBsshInfo();
|
||||
}
|
||||
|
||||
$P.fnSearchProduct = (title) => {
|
||||
$P.productControl.getProductInfo();
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* 버튼 clickEvent
|
||||
**************************************************************************/
|
||||
// 저장
|
||||
$P.fnSave = async() => {
|
||||
// validate 확인
|
||||
if (!customValidate($("#frmEdit--${pageName}").find("input, select, textarea"))) return;
|
||||
|
||||
let bsshData = $P.bsshFormFields.get();
|
||||
|
||||
|
||||
if(bsshData.bsshCd == ""){
|
||||
dialog.alert({
|
||||
content: "마약류 취급업체 정보를 입력해주세요."
|
||||
});
|
||||
return false;
|
||||
}
|
||||
// 신규등록인 경우 - 상태 : 신청서접수
|
||||
if(!bsshData.dscdmngId){
|
||||
bsshData.prgrsSttsCd = "01";
|
||||
}
|
||||
|
||||
let dsProd = $P.productList.getDataset();
|
||||
if(dsProd.length == 0){
|
||||
dialog.alert({
|
||||
content: "폐기 제품 정보를 입력해주세요."
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
let fileCount = 0;
|
||||
$("#tbody--productList").find("input[type='file'][name='dsusePrdImgFiles']").each(function() {
|
||||
if(this.dataset.url != null){
|
||||
fileCount++;
|
||||
} else if(this.files[0] != null){
|
||||
fileCount++;
|
||||
}
|
||||
});
|
||||
|
||||
if(dsProd.length != fileCount){
|
||||
dialog.alert({
|
||||
content: "입력되지 않은 폐기 제품 이미지가 있습니다."
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
dialog.alert({
|
||||
content: "현재 폐기 신청서 접수 정보를 저장 하시겠습니까?"
|
||||
, init: () => { setDialogZindex(); }
|
||||
, onOK: () => {
|
||||
|
||||
let promiseArr = [];
|
||||
$("#tbody--productList").find("input[type='file'][name='dsusePrdImgFiles']").each(function() {
|
||||
if(this.files[0] != null){
|
||||
let elementFile = this.files[0];
|
||||
promiseArr.push( new Promise(resolve => { resolve(elementFile); }) );
|
||||
} else {
|
||||
let fileInfo = {};
|
||||
fileInfo.URL = this.dataset.url;
|
||||
fileInfo.MIME_TYPE = this.dataset.mimeType;
|
||||
fileInfo.FILE_NM = this.dataset.fileNm;
|
||||
fileInfo.FILE_ID = this.dataset.fileId;
|
||||
promiseArr.push(fnCreateFileFromFileInfo(fileInfo));
|
||||
}
|
||||
});
|
||||
|
||||
Promise.all(promiseArr).then((values) => {
|
||||
$P.control.save(bsshData, dsProd, values);
|
||||
}).catch((error) => {});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//추가
|
||||
$P.fnAdd = () => {
|
||||
if(!$P.productFormFields.get().prductCd){
|
||||
dialog.alert({
|
||||
content: "제품 정보를 입력해주세요."
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
if(isNaN($P.productFormFields.get().dsuseQy)){
|
||||
dialog.alert({
|
||||
content: "폐기 수량은 숫자만 입력 가능합니다",
|
||||
onOK: () => {}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!$P.productFormFields.get().dsuseQy){
|
||||
dialog.alert({
|
||||
content: "폐기 수량을 입력해 주세요"
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
const prdFrm = $P.productFormFields.get();
|
||||
const prdInfo = ""+prdFrm.prductCd+prdFrm.prdValidDe.replaceAll('-','')+prdFrm.mnfNo+prdFrm.mnfSeq;
|
||||
let isDup = $P.productList
|
||||
.getDataset()
|
||||
.filter(item => prdInfo == ""+item.prductCd+item.prdValidDe.replaceAll('-','')+item.mnfNo+item.mnfSeq)
|
||||
.length > 0;
|
||||
if(isDup){
|
||||
const msg = "이미 추가된 제품 입니다<br>제품코드: " + prdFrm.prductCd +"<br>유효기간: "+ prdFrm.prdValidDe +"<br>제조번호: "+ prdFrm.mnfNo +"<br>제조일련번호: "+ prdFrm.mnfSeq;
|
||||
dialog.alert({
|
||||
content: msg
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
const data = {...$P.productFormFields.get(), keyCnt : ""+prdRowKey++};
|
||||
data.prdValidDe = data.prdValidDe.replaceAll('-','');
|
||||
$P.productList.append([data]);
|
||||
}
|
||||
|
||||
$P.fnDel = () => {
|
||||
// validate 확인
|
||||
if (!customValidate($("#frmEdit--${pageName}").find("input, select, textarea"))) return;
|
||||
|
||||
const row = $P.productList.getCurrent();
|
||||
dialog.alert({
|
||||
content: "아래 제품을 삭제하시겠습니까?<br>제품명: "+row.prductNm + "<br>유효기간: " +row.prdValidDe+"<br>제조번호: "+row.mnfNo+"<br>일련번호: " + row.mnfSeq
|
||||
, init: () => { setDialogZindex(); }
|
||||
, onOK: () => {
|
||||
$P.productList.remove($P.productList.getCurrent().keyCnt);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$P.fnChangeDsusePrvCd = () => {
|
||||
// validate 확인
|
||||
let checkData = $("#dsusePrvCd--${pageName} option:selected").val();
|
||||
if (checkData =="01" || checkData =="02") {
|
||||
$("#dsuseAcdtDe--${pageName}").prop('disabled', false);
|
||||
}else{
|
||||
$("#dsuseAcdtDe--${pageName}").prop('disabled', true);
|
||||
$("#dsuseAcdtDe--${pageName}").val("");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* 초기 셋팅
|
||||
**************************************************************************/
|
||||
// 이벤트 설정
|
||||
$P.setEvent = () => {
|
||||
// 안내문 등록 버튼 이벤트
|
||||
$("#btnBsshSearch--${pageName}").on("click", function() {
|
||||
$P.fnSearchBssh($(this).attr("title"));
|
||||
});
|
||||
|
||||
$("#btnProductSearch--${pageName}").on("click", function() {
|
||||
$P.fnSearchProduct($(this).attr("title"));
|
||||
});
|
||||
|
||||
// 버튼 이벤트
|
||||
$("#btnSave--${pageName}").on("click", () => $P.fnSave()); // 저장
|
||||
|
||||
$("#btnAdd--${pageName}").on("click", () => $P.fnAdd()); // 추가
|
||||
|
||||
$("#btnDel--${pageName}").on("click", () => $P.fnDel()); // 추가
|
||||
|
||||
$("#dsusePrvCd--${pageName}").on("change", () => $P.fnChangeDsusePrvCd()); // 추가
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// barcode 입력 처리
|
||||
//-------------------------------------------------------------------------
|
||||
$("#btnProductBarcodeSearch--${pageName}").on("click", () => {
|
||||
$("#prductCd--${pageName}").prop("readonly", false);
|
||||
$("#prductCd--${pageName}").val("");
|
||||
$("#prductCd--${pageName}").focus();
|
||||
});
|
||||
|
||||
$("#prductCd--${pageName}").on("change", () => {
|
||||
let barcode = $("#prductCd--${pageName}").val();
|
||||
if(barcode.length > 20){
|
||||
fnBarcodeSearch(barcode);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// 초기 화면 설정
|
||||
$P.initForm = () => {
|
||||
if($("input[name='prgrsSttsCd']").val() == '99' || ${currentUser.hasAuthorities("ROLE_MANAGER")} || ${currentUser.hasAuthorities("ROLE_ADMIN")}) {
|
||||
$("#btnSave--${pageName}").prop("disabled", true);
|
||||
}
|
||||
initDatepicker("bssh--${pageName}");
|
||||
$("#dsuseAcdtDe--${pageName}").datepicker("setDate", new Date());
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* 최초 실행 함수
|
||||
**************************************************************************/
|
||||
// 1. 이벤트 설정
|
||||
$P.setEvent();
|
||||
|
||||
// 2. 초기 화면 설정
|
||||
$P.initForm();
|
||||
|
||||
// 3. Dataset 설정
|
||||
$P.control.setData([${dsuseReceptInfo}]);
|
||||
|
||||
let productInfo = ${dsuseReceptDtlInfo};
|
||||
let fileInfo = ${fileInfo};
|
||||
|
||||
for(let p of productInfo){
|
||||
p.keyCnt = (""+prdRowKey++);
|
||||
for(let f of fileInfo){
|
||||
if(p.dscdmngSn == f.SUB_TYPE){
|
||||
p.fileInfo = f;
|
||||
}
|
||||
}
|
||||
}
|
||||
$P.productList.append(productInfo);
|
||||
|
||||
$("#tbody--productList tr td input[type=text]").on('change', (e) => {
|
||||
fnPrdChange(e);
|
||||
})
|
||||
});
|
||||
|
||||
</script>
|
Loading…
Reference in New Issue